|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
CFLOOP question
I am looping through items in a shopping cart and need to add up the pricePaul Campano 06/30/03 11:52 A <cfset total = 0>Michael T. Tangorre 06/30/03 11:56 A You can simply add up the column total beforehand. - no need to loop andRobertson-Ravo, Neil (RX) 06/30/03 11:55 A <cfset attributes.total = 0>Nagy, Daniel J 06/30/03 11:57 A In your loop you can doGraham Pearson 06/30/03 11:58 A <cfset total = 0>Adrian Lynch 06/30/03 11:58 A I am looping through items in a shopping cart and need to add up the price of each item to get a total price. How would I do this? I thought about setting a variable "price" per iteration through the loop, but that just gets overwritten each time. Thanks. Paul Campano <cfset total = 0> <cfloop> <cfset total = total + price> </cfloop> Mike ----- Excess quoted text cut - see Original Post for more ----- You can simply add up the column total beforehand. - no need to loop and add them up etc. I am looping through items in a shopping cart and need to add up the price of each item to get a total price. How would I do this? I thought about setting a variable "price" per iteration through the loop, but that just gets overwritten each time. Thanks. Paul Campano <cfset attributes.total = 0> <cfloop index="temp" from=1 to="#ListLen(CartList)# step=1> <cfset attributes.total = attributes.total + CartList[temp]> </cfloop> <cfoutput> My Total Price Is $#attributes.total# </cfoutput> depending on what kind of structure you're holding the cart items in, there may even be a function to do it. --d. I am looping through items in a shopping cart and need to add up the price of each item to get a total price. How would I do this? I thought about setting a variable "price" per iteration through the loop, but that just gets overwritten each time. Thanks. Paul Campano In your loop you can do <cfset TPrice = TPrice + ItemPrice> > I am looping through items in a shopping cart and need to add up the price > of each item to get a total price. How would I do this? I thought about > setting a variable "price" per iteration through the loop, but that just > gets overwritten each time. Thanks. > > Paul Campano <cfset total = 0> <cfloop from="1" to="whatever" index="i"> <cfset total = total + yourPrice> </cfloop> Something along those lines should work. Ade I am looping through items in a shopping cart and need to add up the price of each item to get a total price. How would I do this? I thought about setting a variable "price" per iteration through the loop, but that just gets overwritten each time. Thanks. Paul Campano
|
May 24, 2012
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||