For multiple records of a similar type in a database query, I am attempting to define some checkbox form elements from the query using an array:
[CODE=cfm]
<cfset temp=ArrayNew(1 )>
<cfset i=1>
<cfloop query="myQuery" >
<cfset temp[#i#]=#myQuery.colNa me#>
<cfinput type="checkbox" name="temp[#i#]" value="#temp[i]#"/>
<cfset i=i+1>
</cfloop>
[/CODE]
This seems to work fine in setting up the checkboxes and for returning the correct values when the form is submitted, as the <cfdump> function does display the values as required. However, the variables do not appear as if they are part an array in the <cfdump> display. Instead they appear as normal structure variables such as the 'submit' variable in the form object:
temp[1] {correct value}
temp[2] {correct value}
temp[3] {correct value}
submit 'submit'
etc.
Additionally, when I attempt to reference the variables for further manipulaton, using for example the 'IsDefined' function, the variables cannot be accessed. For example the following does not work:
[CODE=cfm]<cfif IsDefined("form .temp[1]")>[/CODE]
Am I doing this correctly? Can anyone suggest where I am going wrong and what I should be doing instead?
Regards
Blackmore
[CODE=cfm]
<cfset temp=ArrayNew(1 )>
<cfset i=1>
<cfloop query="myQuery" >
<cfset temp[#i#]=#myQuery.colNa me#>
<cfinput type="checkbox" name="temp[#i#]" value="#temp[i]#"/>
<cfset i=i+1>
</cfloop>
[/CODE]
This seems to work fine in setting up the checkboxes and for returning the correct values when the form is submitted, as the <cfdump> function does display the values as required. However, the variables do not appear as if they are part an array in the <cfdump> display. Instead they appear as normal structure variables such as the 'submit' variable in the form object:
temp[1] {correct value}
temp[2] {correct value}
temp[3] {correct value}
submit 'submit'
etc.
Additionally, when I attempt to reference the variables for further manipulaton, using for example the 'IsDefined' function, the variables cannot be accessed. For example the following does not work:
[CODE=cfm]<cfif IsDefined("form .temp[1]")>[/CODE]
Am I doing this correctly? Can anyone suggest where I am going wrong and what I should be doing instead?
Regards
Blackmore
Comment