Thanks for the help Bryan! This worked perfect!
At 12:22 PM 5/15/2001 -0700, you wrote:
>1. surround the whole thing in a loop like this
>
><cfloop from="1" to="#listLen(form.sku)#" index="i">
> <cfset currSku = listGetAt(form.sku,i)>
> <cfset currQty = listGetAt(form.quantity,i)>
>
> [ place existing code here but replace FORM.SKU with currSku and
>replace FORM.QUANTITY with currQty ]
>
></cfloop>
>
>Bryan Love ACP
>Internet Application Developer
>[EMAIL PROTECTED]
>
>
>
>-----Original Message-----
>From: Chad Gray [mailto:[EMAIL PROTECTED]]
>Sent: Tuesday, May 15, 2001 11:26 AM
>To: CF-Talk
>Subject: CFLOOP and multiple variables
>
>
>I have a shopping cart system (part of the one that came with CF Server)
>and i would like to have users be able to order multiple items with
>different quantities. IE a user could order 4 red hammers, 2 blue hammers,
>and 5 green hammers in one click of the button.
>
>When they hit the submit button i get these Form variables.
>
>FORM.SKU = 12,34,23
>FORM.QUANTITY = 1,3,2
>
>Here is my existing code to add the items, but right now it is setup to add
>only one item at a time with one quantity. How can i loop over this code
>with the proper SKU, and Quanity for each part of the form variables
>list? If i use <cfloop INDEX="loopingSKU" LIST="#form.SKU#"> then all i
>can loop is the SKU, the Quantity does not loop.
>
>
> <!--- If the item is already in the basket... --->
> <CFIF ListFind(Session.StoreItems, Form.SKU) NEQ 0>
>
> <!--- Find where in the basket it is --->
> <CFSET ItemPosition = ListFind(Session.StoreItems,
>Form.SKU)>
> <!--- Find out how many of the item are already in the
>basket --->
> <CFSET CurrentQuantity = ListGetAt(Session.StoreQuantities,
>ItemPosition)>
> <!--- Now we add one to what's already in there --->
> <CFSET Session.StoreQuantities =
>ListSetAt(Session.StoreQuantities,
>ItemPosition, CurrentQuantity + Form.Quantity)>
>
> <!--- Otherwise, just add it to the basket --->
> <CFELSE>
>
> <CFSET Session.StoreItems = ListAppend(Session.StoreItems,
>Form.SKU)>
> <CFSET Session.StoreQuantities =
>ListAppend(Session.StoreQuantities,
>Form.Quantity)>
>
> </CFIF>
>
>
>Any help would be appreciated. Hopefully i explained this without making
>it super confusing.
>Thanks,
>Chad
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists