This is the way I handle situations like this. The name of the input field
includes the id. Then you loop through everything in the form scope and
consider whether or not it's one of the ranking fields. If it is, you update
the record. 

form.cfm:
<cfoutput query="gettests">
        ...
        <input type="text" name="rank_#id#" value="#rank#">
        ...
</cfoutput>

action.cfm:
<cfloop collection="#form#" item="key">
        <cfif listFirst(key, "_") eq "rank">
                <cfset id = listRest(key, "_")>
                <cfset value = form[key]>
                <cfquery...>
                        UPDATE  zxcvb
                        SET             asdfg = #value#
                        WHERE           qwert = #id#
                </cfquery>
        </cfif>
</cfloop>



-----Original Message-----
From: eric.creese [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, 8 June 2005 10:56 a.m.
To: CF-Talk
Subject: Loop form input

Okay I am looking for some advice on how to do a loop over a form. Basically
i have a table that list testimonials. for each testimonial record there is
a rank so the user can order the testimonials in the order thy want, so the
value of the rank is displayed in an input text box so they can change the
value of any of the ranks. I have encapuslated the whole table in a FORM. I
want the user to be able to change one or all of the rankingings, select the
submit button and on the action page I want to update each testimonial
record's ranking number. 

Any ideas? I know how to get the infor to the action page but I am not sure
how to loop through and update.

Example
form.cfm
<form>
<cfoutput query=gettests>
<tr><td><input type=hidden name=id value=#id#><input type=text name=rank
value =#rank#></td><tr>
</cfoutput>
<tr><td><input type=submit value=submit</td><tr>
</form>

action.cfm

?????
<CFLOOP INDEX="id" LIST="id">
    <CFOUTPUT>#form.id#-#form.rank#</CFOUTPUT><BR>
</CFLOOP>
????????




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:208913
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to