I've got something like that.  This isn't what you were describing, but you should be 
able to take this core and build what you describe from it without trouble.

Basically what I do is output my variable block of form fields inside of a query loop 
(your example would use a simple index loop).  Then I append a number (a 
queryname.currentrow value, or the loop index value) to a form field name, so I wind 
up with form field names of input1, input2, input3 and so on.  

I also stash the number of repeating lines on the form in a hidden form field.  Call 
it form.ItemCount (although you could also use a session var, client var etc.)

The user fills out the form as usual.

Then on the submit page there's a loop when its time to process the values.  Lets say 
there were three fields:  vehicle year, make and model

<CFLOOP 
   INDEX="LoopCount" 
   FROM=1 
   TO=#form.ItemCount#>
<CFSET variables.CarYear="form.Year#Evaluate(LoopCount)#">
<CFSET variables.CarYear="#Evaluate(variables.CarYear)#">

<CFSET variables.CarMake="form.Make#Evaluate(LoopCount)#">
<CFSET variables.CarMake="#Evaluate(variables.CarMake)#">

<CFSET variables.CarModel="form.Model#Evaluate(LoopCount)#">
<CFSET variables.CarModel="#Evaluate(variables.CarModel)#">
<CFQUERY 
   DATASOURCE="#mysource#">

<!--- run your insert or update query here --->

</CFQUERY>
</cfloop>

If only part of the form is repeating then processing is a bit more complex, but by no 
means undo-able.

HtH,

-------------------------------------------
 Matt Robertson,     [EMAIL PROTECTED]
 MSB Designs, Inc. http://mysecretbase.com
-------------------------------------------


---------- Original Message ----------------------------------
From: "Candace Cottrell" <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
date: Thu, 03 Apr 2003 18:56:29 -0500

>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
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to