Coldfusion cfloop and form error - undefined value error

roger v
roger v used Ask the Experts™
on
I've been trying to debug a CF9 form but everytime I fix one bug, another one crops up! I thought I'd fixed the undefined error, but now I get the following error:

Element chk_approvers_1 is undefined in a Java object of type class coldfusion.filter.FormScope.  
 
 
The error occurred in C:\inetpub\wwwroot\xxxx\xxxx.cfm: line 119
 
117 :                              <td>
118 :                                                 <input type="hidden" name="hChkApprovers_#currentrow#" value="#session.usersmanager#" id="hChkApprovers_#currentrow#">
119 :                                                 <input type="checkbox" name="txt_chk_approvers_#currentrow#" style="size:12px; width:12px; height:12px" value="Y" id="txt_chkApprvrs_#currentrow#" onClick="checkOffApprover(#currentrow#);" <cfif form['chk_approvers_' & currentrow] is "User's Manager">checked="checked"</cfif> />
120 :                                                 <!---<input type="text" name="txt_approvers_#currentrow#" id="txt_approvers_#currentrow#" maxlength="27" style="width:95px; font-size:9px;" value="#REReplace(form['txt_approvers_' & currentrow]," ","","all")#" />--->
121 :                                                 <cfparam name="form.txt_approvers_#currentRow#" default="">
 
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Replace Line 119 : with the below Code

<cfset user = "form.chk_approvers_" & #currentrow#>
 <input type="checkbox" name="txt_chk_approvers_#currentrow#" style="size:12px; width:12px; height:12px" value="Y" id="txt_chkApprvrs_#currentrow#" onClick="checkOffApprover(#currentrow#);" <cfif #user# is "User's Manager">checked="checked"</cfif> />

try this code.. But i am not sure against what you are checking.
Or you are checking against the code with line 118??? Please send the Complete Code i just want to make from where you are getting the form[chk_approvers& Currentrow] Value....

Thanks

Author

Commented:
@Ravi:

Code is attached. Essentially, I'm trying to retrieve the value for the chk_approvers_#currentrow# from the table and if that says "User's Manager", then I set the checked="checked" for the check box. Maybe I should rename that to something else?
<cfif len(strError) eq 0>
		<cfquery name="qryCheckContacts" datasource="#application.datasource#">
			SELECT	process_id
			FROM	tb_process_role_contact
			WHERE	process_id = <cfqueryparam cfsqltype="cf_sql_numeric" value="#val(url.processid)#">
		</cfquery>
		<cfif qryCheckContacts.recordcount gt 0>
			<cfinvoke component="cfc.xxx.xxxx" method="funcGetExistingContacts" returnvariable="qryAllRoles1">
				<cfinvokeargument name="processid" value="#val(url.processid)#">
				<!---<cfinvokeargument name="scopeval2" value="1">--->
			</cfinvoke>
			<cfloop query="qryAllRoles1">
			<cfset form["rolename_"   & qryAllRoles1.currentRow] = qryAllRoles1.rolename>
			<cfset form["txt_admins_"  & qryAllRoles1.currentRow] = qryAllRoles1.admins>
			<cfset form["chk_approvers_"   & qryAllRoles1.currentRow] = qryAllRoles1.RoleNameContactSource>

			<cfset form["txt_approvers_" & qryAllRoles1.currentRow] = qryAllRoles1.approvers>
			<cfset form["txt_escalation_approvers_" & qryAllRoles1.currentRow] = qryAllRoles1.esc_approvers>
			<cfset form["txt_secondlevel_approvers_" & qryAllRoles1.currentRow] = qryAllRoles1.secondlevel_approvers>
			<cfset form["txt_secondlevel_escalation_approvers_" & qryAllRoles1.currentRow] = qryAllRoles1.secondlevel_esc_approvers>
			</cfloop>
			<cfset form.recordCount = qryAllRoles1.recordCount>
			
		<cfelse>
			<cfinvoke component="cfc.xxx.xxxx" method="funcGetExistingRoles" returnvariable="qryAllRoles2">
				<cfinvokeargument name="processid" value="#val(url.processid)#">
				<cfinvokeargument name="scopeval2" value="1">
			</cfinvoke>
			<cfloop query="qryAllRoles2">
				<cfset form["rolename_"   & qryAllRoles2.currentRow] = qryAllRoles2.rolename>
				<cfset form["txt_admins_"  & qryAllRoles2.currentRow] = "">
				<cfset form["chk_approvers_"   & qryAllRoles2.currentRow] = "">
				<cfset form["txt_approvers_" & qryAllRoles2.currentRow] = "">
				<cfset form["txt_escalation_approvers_" & qryAllRoles2.currentRow] = "">
				<cfset form["txt_secondlevel_approvers_" & qryAllRoles2.currentRow] = "">
				<cfset form["txt_secondlevel_escalation_approvers_" & qryAllRoles2.currentRow] = "">
			</cfloop>
			<cfset form.recordCount = qryAllRoles2.recordCount>
		</cfif>
	
     <cfelse>
    	<cfset form.recordCount = form.frmtempItemCounter>
   	</cfif>
<!---end action page--->

<!---this is the actual form code--->
<input type="hidden" name="hChkApprovers_#currentrow#" value="#session.usersmanager#" id="hChkApprovers_#currentrow#">
								<input type="checkbox" name="txt_chk_approvers_#currentrow#" style="size:12px; width:12px; height:12px" value="Y" id="txt_chkApprvrs_#currentrow#" onClick="checkOffApprover(#currentrow#);" <cfif form['chk_approvers_' & currentrow] is "User's Manager">checked="checked"</cfif> />&nbsp;
								<cfparam name="form.txt_approvers_#currentRow#" default=""> 
								<cfset form["txt_approvers_#currentRow#"] = replace(form["txt_approvers_#currentRow#"], " ","", "all")>
								<input type="text" name="txt_approvers_#currentrow#" id="txt_approvers_#currentrow#" maxlength="27" 
       style="width:95px; font-size:9px;" value="#form['txt_approvers_' & currentrow]#" />

Open in new window

Author

Commented:
@ravi:

I tried using this code:


<cfset user = "form.chk_approvers_" & #currentrow#>

No luck, gives the same error.

Author

Commented:
OK it works now. Hopefully it'll stay that way. :)  thanks much Ravi!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial