House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

CFLOOP question

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
<cfset total = 0>
Michael T. Tangorre
06/30/03 11:56 A
<cfset attributes.total = 0>
Nagy, Daniel J
06/30/03 11:57 A
In your loop you can do
Graham Pearson
06/30/03 11:58 A
<cfset total = 0>
Adrian Lynch
06/30/03 11:58 A
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Paul Campano
06/30/2003 11:52 AM

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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Michael T. Tangorre
06/30/2003 11:56 AM

<cfset total = 0> <cfloop> <cfset total = total + price> </cfloop> Mike ----- Excess quoted text cut - see Original Post for more -----

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Robertson-Ravo, Neil (RX)
06/30/2003 11:55 AM

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

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Nagy, Daniel J
06/30/2003 11:57 AM

<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

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Graham Pearson
06/30/2003 11:58 AM

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

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Adrian Lynch
06/30/2003 11:58 AM

<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


<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

May 24, 2012

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
     1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31     

Designer, Developer and mobile workflow conference