Sounds like a plan, thanks Gel. I'll try it out when I get home :) okies?? ;) Candace K. Cottrell, Web Developer The Children's Medical Center One Children's Plaza Dayton, OH 45404 937-641-4293 http://www.childrensdayton.org [EMAIL PROTECTED]
>>> [EMAIL PROTECTED] 4/4/2003 8:25:30 AM >>> Hmm...could just check if they are empty?? And only add to the database if they are not empty? So loop over the fields during the insert query, and only run the insert query if the field is NEQ "". So even if they select 15 records and only actually fill out 5 you won't try to insert anything. <CFLOOP FROM="1" TO="#form.Numforms#" index="j"> <CFIF form.Name_#j# NEQ ""> <CFQUERY name="insertrecords" datasource="#DSN#"> .. .. .. </CFQUERY> </CFIF> </CFLOOP> ?? Okies..maybe not.. *sneaks away quietly* -Gel -----Original Message----- From: Candace Cottrell [mailto:[EMAIL PROTECTED] Thanks to Matt and Philip for helping out with this. I have the form page displaying correctly now. HOWEVER, (and there always is one with me) I thought of one of those user-error things. What if the user tells the page she wants to add 10 records, but only fills in eight of them? If I use the initial loop value (which I am calling NumForms) there will be empty records added. Any ideas? Candace K. Cottrell, Web Developer The Children's Medical Center One Children's Plaza Dayton, OH 45404 937-641-4293 http://www.childrensdayton.org [EMAIL PROTECTED] >>> [EMAIL PROTECTED] 4/4/2003 5:09:07 AM >>> Similar to Matt's solution, but name your Form fields with a numeric extension <input type="text" name="Name_#i#" value="#HTMLeditFormat(Form["Name_#i#"])#"> Then when you're inserting, just use the form["Name_#i#"] Remember to pass the number of entries along with the form, otherwise you won't know how many to loop over I'd use the underscore to separate the field name from the number HTH > -----Original Message----- > From: Candace Cottrell [mailto:[EMAIL PROTECTED] > Sent: Friday, April 04, 2003 12:56 AM > To: CF-Talk > Subject: Multiple forms, looping and inserting > > > Ok, so I have an idea, but I'm not sure how to carry it through. > > I have a basic insert record page. However, I want the person to be > able to add 5, 10, or 15 records at a time, depending on the value > they select from a drop-down. Meaning, depending on how many they want > to add, there will be that many forms, and one submit button to add > all the records. > > I'm thinking I need a loop somewhere, but not sure where. > > Any help is greatly appreciated! > > Here's what I have so far: > > addSite.cfm: > > > <form name="MultiForm" > action="addSite.cfm?MultiForm=TRUE&NumForms=#NumForms#"> > <select name="NumForms"> > <option value="5">5</option> > <option value="10" selected>10</option> > <option value="15">15</option> > </select> > <input name="" type="submit" value="Show"> > </form> > > <cfif MultiForm IS True> > <form action="addSite2.cfm" method="post" name="addSite"> > <cfloop from="0" to="URL.NumForms" index="i"> > <table width="100%" border="0" cellspacing="2" cellpadding="5"> > <tr> > <td width="24%" class="copyTeal"><div align="right">Author Name: > </div></td> > <td width="76%"><input name="Website_author" type="text" > id="Website_author"></td> > </tr> > <tr> > <td class="copyTeal"><div align="right">Website link:</div></td> > <td><p> > <input name="Website_Link" type="text" id="Website_Link" > size="45"> > </p> > <p><span class="tealHeader">Please include the http:// and > remember to > verify the link's accuracy.</span></p></td> > </tr> > </table> > <p class="tealHeader"> > <input type="submit" value="Continue"> > </p></cfloop> > </form> > > <cfelse> > <form action="addSite2.cfm" method="post" name="addSite"> > <table width="100%" border="0" cellspacing="2" cellpadding="5"> > <tr> > <td width="24%" class="copyTeal"><div align="right">Author Name: > </div></td> > <td width="76%"><input name="Website_author" type="text" > id="Website_author"></td> > </tr> > <tr> > <td class="copyTeal"><div align="right">Website link:</div></td> > <td><p> > <input name="Website_Link" type="text" id="Website_Link" > size="45"> > </p> > <p><span class="tealHeader">Please include the http:// and remember to verify the link's accuracy.</span></p></td> </tr> </table> <p class="tealHeader"> <input type="submit" value="Continue"> </p> </form> </cfif> The problem is that the page is trying to run the loop regardless of if the upper form has been submitted or not. And then it says that my "to" value is invalid because it isn't a simple data type. Thanks for taking the time to read my rambling :) Candace K. Cottrell, Web Developer The Children's Medical Center One Children's Plaza Dayton, OH 45404 937-641-4293 http://www.childrensdayton.org [EMAIL PROTECTED] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| 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 Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4