Just to recap, on a form I have:

<INPUT type="checkbox" name="AO_ORDER" value="1"> <INPUT type="text"
name="AO_QUANT" >
<INPUT type="checkbox" name="AO_ORDER" value="2"> <INPUT type="text"
name="AO_QUANT" >
<INPUT type="checkbox" name="AO_ORDER" value="3"> <INPUT type="text"
name="AO_QUANT" >
<INPUT type="checkbox" name="AO_ORDER" value="4"> <INPUT type="text"
name="AO_QUANT" >

Having GREAT difficulty getting this to write to a database properly (I
didn't design the form, they handed it off and said, "Make it work"!)

I'm trying to find different methods to cure my problem.  Below seems to
work just fine (thanks Patricia) , BUT only if you have matched pairs coming
off the form (AO_ORDER and AO_QUANT on the same row of the form have data)
If some idiot doesn't fill them out as a matched pair, it writes incorrectly
to the database:


<CFSET ITEMS = "#form.AO_ORDER#">
<CFSET AMOUNT = "#form.AO_QUANT#">

<CFSET COUNTER = 1>

<CFLOOP LIST = "#ITEMS#" INDEX = "ITEMS">

             <CFQUERY name="ORDERS" datasource="AO_LITERATURE">

                  INSERT INTO PRODUCT_ORDERS (AO_ORDER, AO_QUANT)
                  VALUES ('#ITEMS#', '#ListGetAT(AMOUNT,COUNTER)#')

             </CFQUERY>
         <CFSET COUNTER = COUNTER + 1>

</CFLOOP>


So, with that in mind, using this method, any way to be SURE there's a
matched pair? Even if not, I see some uses for the above.

Jim McAtee presented a good idea as well. Going to play with that one next.

--
Les Mizzell
****************
Who Needs Intel?
ATHLON INSIDE!



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to