![]() |
| Multiple record insert |
|
shill
|
I am stumped with some code would appreciate any suggestions.
I have a form used for requesting documents and it contains about 5 text fields and six checkboxes. For every box that is checked, I need to insert a new row in a table which has a requestID, requestTypeID and documentID. My plan was to loop over the form fields to get the IDs and do the insert via CFLOOP, but I am not having any luck.
Any suggestions? Recommendations and code corrections are welcomed! |
||||||||||||||
|
|
|||||||||||||||
| Re: Multiple record insert |
|
Jason101
Forum Regular
|
If you name all the check boxes the same (but with different values), the values will be put into that variable as a list. So all you need to do is loop over the list to do your inserts.
Example: The form field passed is called DocumentIDs and that Form variable now contains : 10,22,19,15 So you'll loop over that field: <cfloop list="#Form.DocumentIDs#" index="item"> <cfquery name="insDocRequestData" datasource="mydatasource"> INSERT INTO requestList (requestID, requestTypeID, docID) VALUES (#insRequest.NewRequestID#, <!---ID coming from another insert---> #Evaluate(form.requestTypeID)#, #item#) </cfquery> </cfloop> Is this what you are trying to do? |
||||||||||||
|
|
|||||||||||||
|
shill
|
Hi Jason,
Yep, that's it! Thanks for your help. Much appreciated. |
||||||||||||
|
|
|||||||||||||
| Multiple record insert |
|
||
|


