Skip to main content
Known Participant
July 11, 2013
Question

dynamic name

  • July 11, 2013
  • 1 reply
  • 2021 views

Hi,
I have the form is displayed with several text boxes.  The checkbox is displayed beside each field which has it own ID.  If i check three checkboxes then hit next, i'd like to see it passed three diffrent IDs' passed to next.cfm page.  Can someone please help how to pass value with dynamic name?


<!---form.cfm--->
<cfform name="update" method="post" action="next">
    <cfloop query="q_cat">
    ......
    <cfinput type="checkbox" id="cat" name="update_#id#" value="#id#">
    <cfinput type="submit" name="next" value="Next">
    </cfloop>
</cfform>

<!---next.cfm--->
  <cfoutput>
  #evaluate("update.#id#")#
  </cfoutput>

thank you

    This topic has been closed for replies.

    1 reply

    p_sim
    Participating Frequently
    July 11, 2013

    <!--- next.cfm --->

    <cfloop query="q_cat">

              <cfif structKeyExists(form, "update_" & id)>

                        <cfoutput>#form["update_" &id]#</cfoutput>

              </cfif>

    </cfloop>

    newcfAuthor
    Known Participant
    July 11, 2013

    Thanks, but why do you have to put them into cfloop?, cause want to get all ID's passed over so i can do the query for those ID's.

    p_sim
    Participating Frequently
    July 11, 2013

    Because we don't know which checkboxes are checked. A checkbox is not defined in the form scope if not checked. That's why I put it in the loop and evaluate which checkboxes are checked.