Skip to main content
November 15, 2009
Answered

Looping and incrementing FORM.Value_#

  • November 15, 2009
  • 1 reply
  • 461 views

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

This topic has been closed for replies.
Correct answer -__cfSearching__-

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]

1 reply

-__cfSearching__-Correct answer
Inspiring
November 15, 2009

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]

November 15, 2009

Thanks! That works beautifully.

Greg

Inspiring
November 15, 2009

You are welcome... and Happy Sunday

-Leigh