I need to set structure variables within an array using the loop
counter.
The form variables being passed are in the format:
op_1
op_2
op_3
I've used form associative arrays to do this in the past
successfully...but I'm having trouble setting these. This is my code:
<cfloop from="1" to="10" index="i">
<CFSET session.cart[arrayLen(session.cart)].options.op_#x# = #form
["op_#i#"]#>
</cfloop>
It's erroring out as:
==========================================
Invalid CFML construct found on line 117 at column 65.
ColdFusion was looking at the following text:
#
The CFML compiler was processing:
A CFSET tag beginning on line 117, column 12.
A CFSET tag beginning on line 117, column 12.
A CFSET tag beginning on line 117, column 12.
The error occurred in C:\Inetpub\wwwroot\test\cart\cart.cfm: line 117
115 :
116 : <cfloop from="1" to="10" index="x">
117 : <CFSET session.cart[arrayLen(session.cart)].options.op#x# =
#ops#>
118 : </cfloop>
119 :
=============================================
Anyone know what the problem is? Thanks
Bob Dively - 28 Jan 2010 18:37 GMT
> <cfloop from="1" to="10" index="i">
> <CFSET session.cart[arrayLen(session.cart)].options.op_#x# = #form
> ["op_#i#"]#>
> </cfloop>
I'd go with:
<CFSET session.cart[arrayLen(session.cart)].options["op_" & i] = form["op_" & i] >
(Assuming that "op_#x#" in your example is supposed to be
"op_#i#".)

Signature
Bob Dively | I used to be indecisive, but now I'm not sure...