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

Cannot loop over struct formfields

Guest
Mar 22, 2012 Mar 22, 2012

Copy link to clipboard

Copied

This appears in my dump var:

struct

ACTIONupdateRecordsListings

FIELDNAMESITEMORDER[],ACTION

ITEMORDER[]558,559,536,478,469,468,466,465,464,397,191,11,175

I cannot get it to work to loop over the itemorders and output them. I know it's simple but cannot get it to work.

Here's my code:

<cfloop index="i" from="1" to="#ArrayLen(form)#">
<cfoutput>
  #form.itemorder#

</cfoutput>
</cfloop>

Thank you very much in forward.

TOPICS
Getting started

Views

879

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
Valorous Hero ,
Mar 22, 2012 Mar 22, 2012

Copy link to clipboard

Copied

#ArrayLen(form)#">

FORM is a structure, not an array.

#form.itemorder#

Adding square brackets to multiple form field names does not create an array. It just creates a single field literally named "ITEMORDER[]". The value of the field is a comma separated string. To access the value you need to use associative array notation (due to the special characters in the field name ie "[]"). 

         <cfset theCSVList = FORM["itemorder[]"]>

Once you have the value you can cfloop through it as a "list". You could also convert it to an array explicitly and use <cfloop array="...">

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
Guest
Mar 22, 2012 Mar 22, 2012

Copy link to clipboard

Copied

Thanx Search for this insight.

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
Community Expert ,
Apr 01, 2012 Apr 01, 2012

Copy link to clipboard

Copied

LATEST

If itemorder is an array, then this should work:

<cfloop index="i" from="1" to="#ArrayLen(itemorder)#">
<cfoutput>
  #itemorder#<br>

</cfoutput>
</cfloop>

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