Change: <cfinput type="checkbox" value="1" name="org" />#org_abbr#<br> <input type="hidden" name="org_id" value="#list.id#">
To: <cfinput type="checkbox" value="#list.id#" name="org_id" />#org_abbr#<br> Then on your action page your Form.org_id field will be a comma-delimited list of org_id's. Then you can just do this: <cfif IsDefined('form.action')> <cfif IsDefined("Form.org_id") AND ListLen(Form.org_id) GT 0> <cfloop list="#Form.org_id#" index="i"> <cfquery name="addorg" datasource="#DSN#"> INSERT INTO org_admin ( users_id, org_id ) VALUES ( #form.users_id#, '#i#' ) </cfquery> </cfloop> </cfif> </cfif> > -----Original Message----- > From: Jillian Carroll [mailto:[EMAIL PROTECTED] > Sent: Wednesday, February 26, 2003 9:53 AM > To: CF-Talk > Subject: Dynamic Insert > > > I've been working on this for a while and I've created a test page > before I move this over to my full form. > > How can I create a loop that will allow my insert to work? > > This is what I have: > > <cfif IsDefined('form.action')> > <cfquery name="addorg" datasource="#DSN#"> > INSERT INTO org_admin (users_id, org_id) > VALUES (#form.users_id#,'#form.org_id#') > </cfquery> > </cfif> > > <!--- GENERIC QUERIES AND VARIABLE SETTING ---> > > <cfquery name="list" datasource="#DSN#"> > SELECT * FROM organizations ORDER BY org_abbr > </cfquery> > > <!--- END GENERIC QUERIES AND VARIABLE SETTING ---> > > <cfform action="" method="post"> > <table border="0" cellpadding="0" cellspacing="0"> > <tr> > <td colspan="3"> > <table cellpadding="2" cellspacing="0" width="100%"> > <tr> > <td>Please select the Lung Associations that this user is > responsible for:</td> > </tr> > <tr> > <td> > <CF_Columns Cols="3" Records="#list.RecordCount#"> > > <table border="0" cellpadding="2" cellspacing="0" > width="100%"> > <tr> > <!--- Loop through the number of columns desired. ---> > <cfloop index="LoopCount" from="1" to="3"> > <!--- Access the start and end variables created by the custom > tag. ---> > <cfset #start# = ("start" & #LoopCount#)> > <cfset #end# = ("end" & #LoopCount#)> > <td valign="top"> > <cfoutput query="list" startrow="#Evaluate(start)#" > maxrows="#Evaluate(end)#"> > <cfinput type="checkbox" value="1" name="org" /> > #org_abbr#<br> > <input type="hidden" name="org_id" value="#list.id#"> > </cfoutput> > </td> > </cfloop> > </tr> > </table> > </td> > </tr> > </table> > <br /> > </td> > </tr> > <tr> > <td width="25%"> </td> > <td colspan="3"> > <cfoutput><input type="hidden" name="users_id" > value="#url.id#"></cfoutput> > <input type="hidden" name="action" value="add"> > <input type="submit" name="Submit"> > </td> > </tr> > </table> > </cfform> > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting. Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4