Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cfloop collection question

Status
Not open for further replies.

pixiesfb

Programmer
Apr 27, 2001
62
US
I've never done a cflloop collection before,

I'm submitting this form to submit.cfm....

<form action=&quot;submit.cfm&quot; method=&quot;POST&quot;>
<cfoutput query=&quot;list&quot;>
<tr>
<td>
<input type=&quot;hidden&quot; value=&quot;#ID#&quot; name=&quot;ID&quot;>
<input type=&quot;Text&quot; name=&quot;QuestionOrder_#ID#&quot; value = &quot;#questionorder#&quot;>
</td>
</tr>
</cfoutput>
</form>

I'm trying to use this (which I know is wrong and doesn't work at all):

<cfloop collection=&quot;#forms.id#&quot; item=&quot;QuestionOrder&quot;>
<cfoutput>
#QuestionOrder# equals #Form[QuestionOrder]#<br>
</cfoutput>
</cfloop>

How do I make this work..?
 
The variable FORM.Fieldnames in ColdFusion is a comma deliniated list of the fields from the submitted form. So just loop through that list.

<cfloop index=&quot;FormFieldName&quot; list=&quot;#FORM.Fieldnames#&quot;>
<cfset FormFieldName = &quot;FORM.&quot; & Variables.FormFieldName>
<cfoutput>
#Variables.FormFieldName#: #Evaluate(Variables.FormFieldName)#<br>
</cfoutput>
</cfloop>


- tleish
 
Try this:
(
CF 4.0 method
<cfloop list=&quot;#Form.FieldNames#&quot; index=&quot;ThisField&quot;>
<cfoutput>
#ThisField# equals #evaluate(&quot;Form.#ThisField#&quot;)#<br>
</cfoutput>
</cfloop>

CF 4.5 method
<cfloop collection=&quot;#Form#&quot; item=&quot;ThisField&quot;>
<cfoutput>
#ThisField# equals #Form[ThisField]#<br>
</cfoutput>
</cfloop>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top