Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Looping and incrementing FORM.Value_#

New Here ,
Nov 15, 2009 Nov 15, 2009

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

TOPICS
Advanced techniques
406
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Nov 15, 2009 Nov 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]

Translate
Valorous Hero ,
Nov 15, 2009 Nov 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]

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 15, 2009 Nov 15, 2009

Thanks! That works beautifully.

Greg

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Nov 15, 2009 Nov 15, 2009
LATEST

You are welcome... and Happy Sunday

-Leigh

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources