Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Variable not passing to action

Status
Not open for further replies.

roropacific

IS-IT--Management
Jun 29, 2002
23
US
Hello I am knew to cold Fusion. Here is my problem I have a form with one field and a submit button. When I enter something in the field and press submit.
I get this error
Error Diagnostic Information

An error occurred while evaluating the expression:


#form.searchvar#



Error near line 3, column 12.
--------------------------------------------------------------------------------

Error resolving parameter FORM.SEARCHVAR


The specified form field cannot be found. This problem is very likely due to the fact that you have misspelled the form field name.



The error occurred while processing an element with a general identifier of (#form.searchvar#), occupying document position (3:11) to (3:26) in the template file C:\Inetpub\
This is what I have in my form
<CFOUTPUT>
<CFAPPLICATION NAME='search' SESSIONMANAGEMENT='YES' SESSIONTIMEOUT='#CreateTimeSpan(00, 00, 60, 00)#'>
</CFOUTPUT>
<html>
<head><title>Customer Support Search</title></head>
<body>
<h1>Search</h1><br><hr>


<p>Select from the following reporting options to view data:</p>
<p>Enter Product Id:</p>
<p><input type=&quot;text&quot; name=&quot;#searchvar#&quot;>

</p>
<form method=&quot;post&quot; action=&quot;search.cfm&quot; >
<INPUT type=&quot;submit&quot; value=&quot;Search&quot;>


<br><br><br>
<A href=&quot;customerservice1.cfm&quot;> Back</A> </br></br></br>

any clue?
Thank you
 
The most important thing would be to learn how to use a form, at this point coldfusion is not the problem.

Try this website to get you started with forms:

A couple of quick notes:
1. you do not have a <form> tag.
2. the #searchvar# goes in the &quot;value&quot; parameter.

Kris
 
You need to put the SEARCHVAR input tag within the <FORM> tag for it to show up on the action template.

HTH,

Phil Hegedusich
Senior Web Developer
IIMAK
-----------
Boy howdy, my Liberal Studies degree really prepared me for this....
 
Hi,

A few things:

1) The CFAPPLICATION should go into your Application.cfm file, although it will work in the file, it is best to put it in the Application.cfm

2) This is the definition of the input field on the page:

<input type=&quot;text&quot; name=&quot;#searchvar#&quot;> but there doesn't seem to be a value for searchvar defined on the page using a CFSET, and even if there was then there is no CFoutput surrounding #searhvar# for CF to parse it anyway. You don't really need to use a CF variable as a name for the field, you could just use a static value.

3) Your form tag is not surrounding the text field, and will not pass the value that you enter.

Change the page to something like the following:

<form method=&quot;post&quot; action=&quot;search.cfm&quot; >
<input type=&quot;text&quot; name=&quot;searchvar&quot;><BR>
<!--- or if you want to use a CF vbl to define the name of the field--->
<CFSET fieldname = &quot;searchvar2&quot;>
<cfoutput>
<input type=&quot;text&quot; name=&quot;#fieldname#&quot;>
</cfoutput>
<INPUT type=&quot;submit&quot; value=&quot;Search&quot;>
</form>

then on your search.cfm page you can use the code that you already have:

<cfoutput>
#Form.SearchVar#<BR>
#Form.SearchVar2#
</cfoutput>

Hope this helps!

Tony
 
Thank you for clearing that up. Now the search.cfm appears to be not working. My browser just refreshes.
Here is my action file &quot;search.cfm&quot;
<CFPARAM NAME=DATASRC DEFAULT=custsrvc>
<cfoutput>#form.searchvar# </cfoutput>
<CFQUERY NAME=GETITEMS DATASOURCE=#DATASRC#>
SELECT * FROM complaint where product_id like '#form.searchvar#%'
</CFQUERY>
<CFOUTPUT>
<TABLE BORDER=1 CELLPADDING=1 CELLSPACING=1 ALIGN=CENTER bgcolor=&quot;cccccc&quot; >

<TR>
<TD ALIGN=CENTER>
<FONT COLOR=FFFFFF STYLE=&quot;font-size: 12px&quot; FACE=&quot;Arial&quot;>
Agent
</FONT>

</td>
<TD ALIGN=CENTER>
<FONT COLOR=FFFFFF STYLE=&quot;font-size: 12px&quot; FACE=&quot;Arial&quot;>
Product ID
</FONT>
</TD>

<TD ALIGN=CENTER>
<font COLOR=FFFFFF STYLE=&quot;font-size: 12px&quot; FACE=&quot;Arial&quot;>
Issue Summary
</FONT>
</TD>

<TD ALIGN=CENTER>
<FONT COLOR=FFFFFF STYLE=&quot;font-size: 12px&quot; FACE=&quot;Arial&quot;>
Issue Description
</FONT>
</TD>

<TD ALIGN=CENTER>
<FONT COLOR=FFFFFF STYLE=&quot;font-size: 12px&quot; FACE=&quot;Arial&quot;>
Current Date
</FONT>
</TD>

<TD ALIGN=CENTER>
<FONT COLOR=FFFFFF STYLE=&quot;font-size: 12px&quot; FACE=&quot;Arial&quot;>
Location of Purchase
</FONT>
</TD>

<TD ALIGN=CENTER>
<FONT COLOR=FFFFFF STYLE=&quot;font-size: 12px&quot; FACE=&quot;Arial&quot;>
Date of Purchase
</FONT>
</TD>

<TD ALIGN=CENTER>
<FONT COLOR=FFFFFF STYLE=&quot;font-size: 12px&quot; FACE=&quot;Arial&quot;>
Tracking Number
</FONT>
</TD>
</TR>

<CFLOOP QUERY=GETITEMS>
<TR>
<TD>
<FONT COLOR=FFFFFF STYLE=&quot;font-size: 12px&quot; FACE=&quot;Arial&quot;>
#GETITEMS.username#
</FONT>
</A>
</TD>

<td>
<FONT COLOR=FFFFFF STYLE=&quot;font-size: 12px&quot; FACE=&quot;Arial&quot;>
#GETITEMS.product_id#

</FONT>
</A>
</td>

<td>
<font COLOR=000000 STYLE=&quot;font-size: 12px&quot; FACE=&quot;Arial&quot;>
#GETITEMS.issue_summary#
</FONT>
</TD>

<TD>
<FONT COLOR=000000 STYLE=&quot;font-size: 12px&quot; FACE=&quot;Arial&quot;>
#GETITEMS.issue_description#
</FONT>
</TD>

<TD>
<font COLOR=000000 STYLE=&quot;font-size: 12px&quot; FACE=&quot;Arial&quot;>
#GETITEMS.currentdate#
</FONT>
</TD>

<TD>
<FONT COLOR=000000 STYLE=&quot;font-size: 12px&quot; FACE=&quot;Arial&quot;>
#GETITEMS.locationofpurchase#
</FONT>
</TD>

<TD>
<FONT COLOR=000000 STYLE=&quot;font-size: 12px&quot; FACE=&quot;Arial&quot;>
#GETITEMS.dateofpurchase#
</FONT>
</TD>

<TD>
<FONT COLOR=000000 STYLE=&quot;font-size: 12px&quot; FACE=&quot;Arial&quot;>
#GETITEMS.issueid#
</FONT>
</TD>
</TR>

</CFLOOP>


</TABLE>


</CFOUTPUT>


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top