Title: Looping over a form
 <cfloop index="item" list="#form.fieldnames#" delimiters=",">
    <cfoutput>
            <cfset myFormField = "form." & item>
            form.#item#  = #evaluate(myFormField)#
    </cfoutput>
</cfloop>
 
Starting in either CF5 or CF4.5 the form scope became a structure so you could loop using the collection version of cfloop instead of the list version.
 
By the way
You can do this with a query too. Substitute myQueryNam.columnList for form.fieldnames and loop through the columns of a table without haveing to know what the column names are.
 
-steve
 

Steve Budan
Cold Fusion Developer
Baxter Corporation
AUTROS POINT OF CARE System
One Yorkdale Road, Suite 310
Toronto, ON M6A 3A1
(416) 784-1100 ext. 182

-----Original Message-----
From: Dave Boehm [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 26, 2002 3:53 PM
To: [EMAIL PROTECTED]
Subject: [CFTALKTor] Looping over a form

I have an action page on which I'd like to loop through a passed form and get the names and values of each form element. I don't know how many form elements there may be or what their names are but I do know the name of the form. I can do this in Javascript (I believe) but is it possible in ColdFusion?


David Boehm
Website & Database Management
Product Ordering On-Line
M&T Printing Group
907 Frederick St. Kitchener, ON Canada
N2B 2B9
(519) 571-0101  Fax (519) 571-0129
[EMAIL PROTECTED]


Reply via email to