Skip to main content
Participant
April 26, 2007
Question

undefined <VARIABLE> in FORM

  • April 26, 2007
  • 4 replies
  • 424 views
Dear All,

Another post with a classic "undefined <VARIABLE> in FORM" error message I'm afraid. I don't think this is the usual problem of scoping however or form not submitting the data. Basically I've checked and triple checked the file with the <cfform> tag in it and it definately contains the relevant controls with the names correct. I've also put <cfdump var="#Form#"><cfabort> tags at the top of each file to ensure the information is getting through. Looking at the Form structure I can see the variables that are being posted (all of which have the values passed from the file with the form tag). However, despite this, when I remove the <cfabort> tag to let the website process then the error message returns. I can't think of what else might be causing this. Any ideas?

The actual .cfm files are pretty long but the jist of them is as follows:

<!-- calling.cfm - a file that contains a form -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>A title</title>
</head>
<body>
<CFSET avariable=10> <!-- In the actual file avariable comes from a database -->
<CFFORM name="aform" action="beingcalled.cfm">
<CFINPUT name="aformvar" type="hidden" value=#avariable#>
<CFINPUT name="action" type="submit" value="Press Me">
</CFFORM>
</body>
</html>

<!-- beingcalled.cfm - a file that has form variables added to it -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>A title</title>
</head>
<body>
<CFDUMP var="#Form#"> <This shows aformvar as part of the form structure>
<!-- Do something with Form.aformvar here -->
<CFIF Form.aformvar EQ 10> <!-- THIS DOESN'T PROCESS - ERROR IS RETURNED -->
I should be displayed
</CFIF>
</body>
</html>

I am using coldfusion 7.

Many thanks in advance,
This topic has been closed for replies.

4 replies

Participating Frequently
April 27, 2007
quote:

The actual .cfm files are pretty long but the jist of them is as follows
I think that the above statement says it all. I wish that I had a dollar for every time that I looked at a piece of code and could swear that there was nothing in it that could be causing "the problem".... yeah, right.

Even if it is long, you might consider posting it if, for no other reason, another pair of eyes may be able to spot the "obvious" problem that your eyes may be skipping over (and over and over.....).

<edit> FYI, I once actually had a CF template that would fail just because it was a certain size... period. It was a few CF versions ago, but if I made the template larger, or smaller, no problem, But I made no actual changes other than size to keep it from failing... very strange, but heck, you never know sometimes </edit>

Phil
Inspiring
April 26, 2007
What happens if, right after this:
<CFDUMP var="#Form#">
you run this
<CFDUMP var="#Form.aformvar#">
??

If that works, how about this?
<cfoutput>#form.aformvar#</cfoutput>

joechip90Author
Participant
April 26, 2007
Thank you all for all your replies,

Trying out the last suggestion:

<cfdump var="#Form#">
<cfdump var="#Form.aformvariable#">
<cfabort>
<cfoutput>#Form.aformvariable#</cfoutput>

Results in the contents of the form structure being displayed to the screen. The second dump then displays the (correct) value of aformvariable to the screen. Removing the <cfabort> tag allows the <cfoutput> tag to process - but sadly displays the same old error message! It seems the form variables ARE being passed - something is going wrong with the processing at the server end it seems.

Hmmmm....
Participating Frequently
April 26, 2007
Make any difference using <cfoutput></cfoutput> tags? (This really should only affect the value of form.avariable passed, not whether or not it is defined on the action page, and now that I think of it, this is probably not the case, since I think that using a cfinput rather than input means that you don't really need cfoutput... oh well.....)

<CFFORM name="aform" action="beingcalled.cfm">
<cfoutput>
<CFINPUT name="aformvar" type="hidden" value=#avariable#>
</cfoutput>
<CFINPUT name="action" type="submit" value="Press Me">
</CFFORM>

Phil
Inspiring
April 26, 2007
I suspect your example may work just fine. You may want to try running
this simple code. If it works then the error is going to be in your
actual code, not the system.

Can you cut and paste a few example lines of your code where it is not
working.