This is a somewhat complex process involving loops and the evaluate function.  I'll 
try to be specific and brief at the same time.

The concept you are describing is exactly the same concept as updating the contents of 
a shopping cart.  The only difference is that you've got more fields.  So as a 
supplement to my comments, try to find samples of how shopping carts work in one of 
the many ColdFusion tutorial sites.

I'm not going to give you all the code because it simply takes too long to build, and 
well, you know - paying clients come first.  But here's the concept:

In the form which people are updating data, you need to create at least one dynamic 
form field name per row of data.  This is your key which you'll use in the processing 
script.

So let's just say your key is "somefieldname".

You create numbers using CFSET, incrementing the number with each row, and appending 
the number you create to the key fieldname: eg. somefieldname#rowcount#.

You also need a total rows count.  Create a number using cfset, increment it with each 
row, set a final variable with the final number, and pass the value through a hidden 
field to the processing script.

eg. <input type="hidden" name="totalrows" value="#totalrows#">

Now, in your processing script, you're going to create a loop to evaluate the form 
field names from the previous page.

To evaluate dynamic form field names, you can use something like the following:

<cfloop index="row" from="1" to="#totalrows#">
        
        <cfset ControlName1 = "Form.somefieldname" & #row#>
        <cfset somefieldname = #Evaluate("#ControlName1#")#>

        Insert whatever logic you want here.  You'll have a key for the particular row 
of data you need to process.
        
</cfloop>

Good luck.

---mark

--------------------------------------------------------------
Mark Warrick
Phone: (714) 547-5386
Efax.com Fax: (801) 730-7289
Personal Email: [EMAIL PROTECTED]
Personal URL: http://www.warrick.net 
Business Email: [EMAIL PROTECTED]
Business URL: http://www.fusioneers.com
ICQ: 346566
--------------------------------------------------------------


> -----Original Message-----
> From: Dharmesh Goel [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, October 17, 2000 1:19 PM
> To: CF-Talk
> Subject: Multiple row form data submission to database?
> 
> 
> Hello Everyone,
> 
> I am trying to make a small data entry screen in ColdFusion. 
> There are five
> columns in the table. Number of rows is dynamically generated 
> with the first
> column automatically filled in. Others have to be filled in by a 
> user. When
> the user submits the form, each row is inserted in a database as 
> a new row.
> 
> I have not done a form submission until now that updates multiple rows. I
> hope you can help me with the basic logic involved in this. My guess would
> be to insert the data from the form into a 2 dimensional Array 
> and then loop
> over the array while inserting into the database. How do I insert 
> it into an
> array and proceed from there?
> 
> CH1           CH2             CH3             CH4             CH5
> ------------------------------------------------------------------
> ----------
> ---------
> Field1                Field2          Field3          Field4          
> Field5
> Field1                Field2          Field3          Field4          
> Field5
> Field1                Field2          Field3          Field4          
> Field5
> Field1                Field2          Field3          Field4          
> Field5
> "             "               "               "               "
> "             "               "               "               "
> 
> Field1 is auto populated with a query result.
> 
> Thank you,
> 
> Dharmesh Goel
> Programmer Analyst
> IT Dept. - Discount Car & Truck Rentals
> 416-744-0123 x290
> 
> ------------------------------------------------------------------
> ------------
> Archives: http://www.mail-archive.com/[email protected]/
> To Unsubscribe visit 
> http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf
_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the 
body.

------------------------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebarRsts or send a message with 
'unsubscribe' in the body to [EMAIL PROTECTED]

Reply via email to