Copy link to clipboard
Copied
I have been programming coldfusion for a while, but this is the first time ive ever needed to add multiple products to a database with 1 submit button. Strange, I know, but I dont want to spend days trying to come up with something when I know there are smarter people out there who probably know a very good way to do this. So here it is:
Here is a screenshot
Copy link to clipboard
Copied
I figured it out. You add a #currentrow# on each of the form items. Then loop through and set up each row before inserting
<cfloop from="1" to="#form.numberOfRows#" index="i">
<cfif form['quantity' & #i#] NEQ ''>
<cfset form.quantity="#form['quantity' & i]#">
<cfset form.itemId="#form['itemid' & i]#">
<cfset form.pricesold="#form['itemprice' & i]#">
<cfinsert datasource="#application.dsn#" tablename="cart">
</cfif>
</cfloop>