Skip to main content
Inspiring
June 2, 2010
Question

submitting a cfform with multiple rows in it

  • June 2, 2010
  • 1 reply
  • 1089 views

so I've got a form that contains several rows, each with a qty input box

how do you loop through all the form items ?

This topic has been closed for replies.

1 reply

ilssac
Inspiring
June 2, 2010

<cfoutput>

<cfloop collection="#form#" item="field">

    #field# = #form[field]# <br/>

</cfloop>

</cfoutput>

OR

<cfoutput>

<cfloop list="#form.fieldNames#" index="field">

  #field# = #form[field]#<br/>

</cfloop>

</cfoutput>

Are just two popular methods.

Inspiring
June 2, 2010

I think I worded that incorrectly.

I need to update corresponding fields in a table based on a form with several rows in it

each row consists of [table_key] and [qty]

whats the best approach ? I've looked all over for info, but I can't seem to accurately describe what I need, to a search engine

eg.

update table

set table.qty = #form.qty#

where table.key = #form.table_key#

when I output the contents of the form, it appears to put each form field in a list eg.

<cfoutput>#form.qty#</cfoutput>

produces 1,3,5,2 (there's 4 qty boxes on the form)

Im just not sure how to a) establish how many list elements there are and b) index through each list element

Inspiring
June 2, 2010

sidenote

I've had some success using listToArray(#form.qty#)

am I on the right track ?