In looking at your code, totalOptPrice shouldn't be overwritten each time,
it is outside of the loop .. are you sure that the listLen is more than 1?

Output your list before the loop to see what you get.

Paul Giesenhagen
QuillDesign

----- Original Message -----
From: "Emmet McGovern" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Tuesday, October 01, 2002 2:52 PM
Subject: list delima


> I know im either overlooking something or i just have no clue.
>
> I have a shopping cart that has options pricing in it, and im having a
> hard time getting the prices of all the options to add up. The option
> IDs are in a ^ delimited list. I need to match the id to the price of
> the option in another table. I can do this fine, but i cant seem to loop
> through and add all the option prices for a sub total.
>
> so how do i get it to add up?
>
> Thanks for any help.
>
> <cfset TotalOptPrice = 0>
>
>      <!--- Find how many options are added to this product, if any
>      <cfloop index="pricenum" from="1" to="#ListLen(Options, "^")#">
>
>                 <!--- Set variable to option price --->
>      <cfset CurrentOptionPrice = #ListGetAt(OptionPrice, PriceNum,
> "^")#>
>      <cfset TotalOptPrice = (#TotalOptPrice# + #CurrentOptionPrice#)>
>
>                 </cfloop>
>
>
> This gives me only the last option price since totaloptprice is being
> overwritten again and again.
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Reply via email to