OK let's go.

Create a form which has for example 10 formfields, with an increasing number, like formfield1, formfield2, etc.
Using cfloop you can easily create more fields

<cfset numberoffields = "10">

<cfform action="" method="POST">

<cfloop index="i" from="1" to="#numberoffields#">

        formfield#i#<cfinput type="Text" value="" name="formfield#i#"><br>

<input type="submit" name="submit" value="Submit">


Now catch the form values when they are submitted.

<!--- check wether the form is submitted --->
<cfif IsDefined ("form.submit")>

<!--- start a loop to loop through the values --->
<cfloop index="i" from="1" to="#numberoffields#">

<!--- dynamically create the form fieldname --->
<cfset formfield = "formfield" & variables.i>

    <!--- output the value of the specific formfield --->
    formfield#i# = #form[variables.formfield]#<br>


About This Tutorial
Author: Mathijs Gaalman
Skill Level: Beginner 
Platforms Tested: CFMX
Total Views: 84,485
Submission Date: February 16, 2005
Last Update Date: June 05, 2009
All Tutorials By This Autor: 1
Discuss This Tutorial
  • You may also want to try this: form.#var# = #evaluate('form.' & var)#


Sponsored By...
Mobile App Development (IOS, Android, Cordova, Phonegap, Objective-C, Java) - Austin, Texas Mobile Apps - Touch512, LLC.