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

Looping dynamic variables

Explorer ,
Jul 29, 2009 Jul 29, 2009

Copy link to clipboard

Copied

Hi

I have the following...

<Cfloop from 1 to 100 index i>

<cfif isDefined ('FORM.JACKET#i#')>
    <cfset jacketsize = #FORM.JACKET#i##>
</cfif>

</cfloop>

I need to know how to get the correct value from #FORM.JACKET#i##

Can anybody assist?

thank you

Delon

TOPICS
Advanced techniques

Views

722

Translate

Translate

Report

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

LEGEND , Jul 29, 2009 Jul 29, 2009

form["jacket" & i]

Votes

Translate

Translate
LEGEND ,
Jul 29, 2009 Jul 29, 2009

Copy link to clipboard

Copied

form["jacket" & i]

Votes

Translate

Translate

Report

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
Explorer ,
Jul 29, 2009 Jul 29, 2009

Copy link to clipboard

Copied

short and sweet!

thank you.

Votes

Translate

Translate

Report

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
Engaged ,
Jul 30, 2009 Jul 30, 2009

Copy link to clipboard

Copied

LATEST

In the context of an HTML incoming data-stream (i.e. FORM), the data will always be "flat."  Therefore, repeating values must be given unique names such as "JACKET18," which you do when building your code.  It is perfectly acceptable thereafter to loop through "all possible values," checking that each one does or doesn't exist, as has been shown.  Browsers vary in their handling of empty-fields:  some browsers include them in the stream while others do not.

Outside of the context of an HTML data-stream, though, in the general sense any element of a Struct may be any sort of complex data-type you care to invent... array, another structure... or a simple data-value such as the numeral "2."  myStruct.jacket could be an array of "jacket description" structures, each one containing who-knows-what.

Votes

Translate

Translate

Report

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
Documentation