multiple inputs

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • celery6541
    New Member
    • Mar 2007
    • 15

    multiple inputs

    Hi all, I need to implement multiple input fields that change depending on selections from the user. For example, A user may be prompted to enter data for multiple inputs who's names are incremented by 1 each time. So there would be
    something like

    Code:
    <cfloop from="1" to="maxsize" index="i">
    <cfselect name="type#i#" size="1" query="get_type" value="ID" display="name">
    </cfselect>
    <cfselect>
    that works just fine, it is when I try to reference the form variable in the next page that things start breaking. If i use Form.type1 or Form.type2 to call the value it will work just fine. However I am not sure how I would use a loop to call the Form variables. Right now I am trying to do something like

    sql statements blah blah
    where band.ID='#Form. type&#i##'

    but the Form.type and i do not concatenate correctly so it keeps erroring.
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Try this:
    [code=cfm]<CFLOOP COLLECTION="#Fo rm#" ITEM="VarName">
    <CFOUTPUT>
    #VarName#: #Form[VarName]#<BR />
    </CFOUTPUT>
    </CFLOOP>[/code]
    or you can use the Form.FieldNames variable which contains all the form variables as a list. You can loop over them and use evaluate to get their values:
    [code=cfm]<CFLOOP INDEX="TheField " list="#Form.Fie ldNames#">
    <CFOUTPUT>#TheF ield# = #Evaluate(TheFi eld)#<BR /></CFOUTPUT>
    </CFLOOP>[/code]
    Last edited by acoder; Apr 2 '12, 01:05 PM.

    Comment

    • celery6541
      New Member
      • Mar 2007
      • 15

      #3
      Thanks! :)

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        You're welcome.

        Comment

        Working...