> >-----Original Message----- >From: Les Irvin [SMTP:[EMAIL PROTECTED]] >Sent: Monday, February 19, 2001 12:35 AM >To: CF-Talk >Subject: Looping over form data? > >I need to pull a number of records at once from a database, edit them on >one page, then send the data back to the database. Looping over the >query, >I've been able to place the data correctly on the page. > >However, I'm at a loss as to how to update the edited records back into >the >database. I'm currently trying to post them as form data but it fails >because each record's input fields have the same name. > >Is there a way to loop over form data or to dynamically rename form >fields? >And/or is there a better way to edit multiple records at once than by >using >a form? Aside from the aforementioned CFGRID, which is probably the easiest CF-specific way to do it (all in one go!), the alternative is likely to be something like this: When first looping the records to be displayed on screen, add the current row number to the end of each form field name. This is so that when you submit the form back again, CF will get form variables called name1, address1, name2, address2 etc etc (or whatever). You should know how many iterations you get back (after all, you put them on-screen in the first place!). Once you get the form back, just loop over that number, break off the suffix digit to get the 'proper' field name, and check/update/insert back into the database as appropriate. Send the ID of the database record as a hidden field to make it easy on the way back too. You can use this method to create 'check-the-box' fields to mass-delete records at the same time... Regards, SB Scott Bartlett ([EMAIL PROTECTED]) BTA Limited 100 High Street Wandsworth London SW18 4LA United Kingdom Tel:020 8871 4240 Fax:020 8871 4584 http://www.bta.com Network Consultancy and Support for Windows 9x/NT and MacOS. Internet connectivity, solutions, and business services. This message is intended only for the use of the person(s) ("The intended recipient(s)") to whom it is addressed. It may contain information which is privileged and confidential within the meaning of applicable law. If you are not the intended recipient, please contact the sender as soon as possible. The views expressed in this communication may not necessarily be the views held by BTA. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists