Skip navigation
Flashhhgordon
Currently Being Moderated

Cannot loop over struct formfields

Mar 22, 2012 3:40 AM

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[i]#

</cfoutput>
</cfloop>

 

Thank you very much in forward.

 
Replies
  • Currently Being Moderated
    Mar 22, 2012 6:49 AM   in reply to Flashhhgordon

    #ArrayLen(form)#">

     

    FORM is a structure, not an array.

     

    #form.itemorder[i]#

     

    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="...">

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 1, 2012 1:56 AM   in reply to Flashhhgordon

    If itemorder is an array, then this should work:

     

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

    </cfoutput>
    </cfloop>

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points