Link to home
Create AccountLog in
Avatar of roger v
roger vFlag for United States of America

asked on

Coldfusion form variables - Bug that won't go away!


I've been posting this chunk of code for a while and no matter what I do, the same bug keeps popping up and I'm unable to fix it. This is the error I get:

Element txt_approvers_2 is undefined in a Java object of type class coldfusion.filter.FormScope.  
The error occurred in C:\inetpub\wwwroot\xx\xxxx.cfm: line 156
154 :                                                 <input type="hidden" name="hRoleNameContactSource_#currentrow#" value="#form['hRoleNameContactSource_'& currentrow]#">
155 :                                <!--- <cfparam name="form.txt_approvers_#currentrow#" default="">--->
156 :                                                 <cfset variables.user = form['txt_approvers_' & currentrow]>
157 :                                                 <!---User:<cfoutput>#variables.user#</cfoutput>--->
Somebody please help!
Avatar of Zvonko
Flag of North Macedonia image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of roger v



That fixed the error but now I've got another problem - the checkbox is not being checked!  I check the value of the variables.user to see it is "manager" and if it is, I check the checkbox. But now, even though the value is "manager" the checkbox is not being checked.
Avatar of roger v



I'm not using cfform, I'm using a regular form.
When I see such lines then is my first expression is that you are fighting with the field values:

<input type="hidden" name="hRoleNameContactSource_#currentrow#" value="#form['hRoleNameContactSource_'& currentrow]#">

And the solution for that field value handling is the property: preserveData="yes"

Check this:
<cfform name="myform" method="POST" preservedata="yes" >
<cfinput type="text" name="fld1" >
<cfinput type="checkbox" name="yourcheckbox" value="Manager" >
<input type="submit" name="mysub" value="Send" >

Open in new window