Accessing variables of a dynamic form

后端 未结 1 1219
天命终不由人
天命终不由人 2020-12-22 01:54

I am creating a form with cfloop and need to access each variable individually when submitting the form. I need to use the selected entries of the form in a lo

相关标签:
1条回答
  • 2020-12-22 02:39

    You started down the correct path when you added the counter - go back and add that, something like:

    <input type="checkbox" name="amplify#client_admin_surveys.currentRow#" id="amplify">
    

    Would work.

    I also sometimes like to add a form field for the 'counter' on the processing page

    <input type="hidden" name="counter" value="#client_admin_surveys.recordCount#" />
    

    Then on the processing page, you can loop over the counter and access the form fields using bracket notation

    <cfloop from="1" to="#form.counter#" indexd="i">
        <cfset thisAmplify = form["amplify" & i] />
        <cfset thisEnhance = form["enhance" & i] />
        <!---- more logic here --->
    </cfloop>
    
    0 讨论(0)
提交回复
热议问题