I answered a similar question a few days ago.  Am pasting the response again
here.  It might fulfill your need.

The only problem would be if you're allowing the user to check more of one
type of checkbox than another.  The code below will only work properly if
both lists are of the same length, and the information in both lists
correspond from one position to the next.

In any case it might start you thinking even if you can't repurpose it
completely.


|List Functions.
|
|I'm assuming a bit, so let me know if I'm wrong (and I'm sure 
|that others
|have a less cumbersome way to deal with your problem too, so 
|don't think
|what I'm saying is at all the only way).
|
|I'm assuming that Quantity looks something like this: 1,2,3,4,5
|And Item number looks somethiing like this: F004,F005,F006,F007
|
|And F004 has a quantity of 1; F005 has a quantity of 2 etc.
|
|Take a look at this code... I've mocked up the same 
|functionality.... set a
|counter, incremented the counter while looping over one of my 
|lists and then
|used that counter to retreive a list element at the poisitoin 
|represented by
|the counter.
|
|<cfset list1 = "1,2,3,4">
|<cfset list2 = "mom,pop,dad,sis">
|
|<cfset counter = 1>
|<cfloop index="qty" list="#list1#">
|       <cfoutput>
|                       Counter = #counter#             Qty = #qty#
|list2 = #ListGetAt(list2, counter)#<br>
|       </cfoutput>     
|       <cfset counter = counter + 1>
|</cfloop>
|
|
|Output looks like:
|
|Counter = 1 Qty = 1 list2 = mom
|Counter = 2 Qty = 2 list2 = pop
|Counter = 3 Qty = 3 list2 = dad
|Counter = 4 Qty = 4 list2 = sis
|
|So all you'd have to do is loop over your quantity, find the 
|representative
|list element and then input both into the db via your query, 
|which is of
|course nested in the loop.

|-----Original Message-----
|From: Les Mizzell [mailto:[EMAIL PROTECTED]]
|Sent: Thursday, March 08, 2001 9:04 PM
|To: CF-Talk
|Subject: <CFLOOP> Question/Problem
|
|
|I've had good luck using <CFLOOP> to run through a list of 
|checkboxes and
|write single values to record rows in a database.
|
|However, I've now got a PAIR of checkbox/text field that needs 
|to write to
|the same row.
|
|Record in database is set up like:
|
|ID        A0_ORDER        AO_QUANT
|
|On my page, there's probably fifty each AO_ORDER checkbox and 
|AO_QUANT text
|field pairs.
|
|Tried a nested loop like below, and it properly writes the 
|correct pairs to
|the correct rows together, except it writes the values duplicate times.
|
|***************************************************************
|*************
|**
|
|<CFLOOP LIST = "#AO_ORDER#" INDEX = "ITEMS">
|        <CFLOOP LIST = "#AO_QUANT#" INDEX = "QUANT">
|
|            <CFQUERY name="ORDERS" datasource="AO_LITERATURE">
|            INSERT INTO PRODUCT_ORDERS (ORDER_ID, AO_ORDER, AO_QUANT)
|            VALUES ('#CLIENT_ID#', '#ITEMS#', '#QUANT#')>
|            </CFQUERY>
|
|        </CFLOOP>
|</CFLOOP>
|
|***************************************************************
|*************
|**
|
|If you could do something like:
|
|<CFLOOP LIST = "#AO_ORDER#, #AO_QUANT#" INDEX = "ITEMS, QUANT">
|
|instead of the incorrect nested loop it would be nice, but I 
|haven't figured
|out how to get that to work either. Probably a syntax issue.
|
|Advise?
|
|Thanks!!
|
|--
|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