Copy link to clipboard
Copied
Good day,
First time poster here, so be easy on me.
This seems like an easy enough thing. I think I am just having a brainfart because it's Sunday.
Anyways, I have a form that loops a query that increments form values:
value_1
value_2
value_3
etc
When the form is submitted, I want to loop through a predetermined number and set my variable to something like this, but I can't get it to work:
<cfloop from="1" to="#FORM.number#" index="agi">
<cfset myvar = FORM.value_#agi#>
</cfloop>
I am sure it is just a syntax issue, but like I said, it's Sunday
Ideas?
TIA,
Greg
The FORM scope is like a structure. So you can use array notation to access dynamic field names:
myvar = FORM["baseName_"& dynamicPart]
ie myvar = FORM["value_"& agi]
Copy link to clipboard
Copied
The FORM scope is like a structure. So you can use array notation to access dynamic field names:
myvar = FORM["baseName_"& dynamicPart]
ie myvar = FORM["value_"& agi]
Copy link to clipboard
Copied
Thanks! That works beautifully.
Greg
Copy link to clipboard
Copied
You are welcome... and Happy Sunday
-Leigh