Avatar of roger v
roger v
Flag 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!
ColdFusion Language

Avatar of undefined
Last Comment

8/22/2022 - Mon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
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.

roger v


I'm not using cfform, I'm using a regular form.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes

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