This content has been marked as final.
Show 5 replies

1. Re: Math Evaluate
Charlie Griefer Dec 7, 2006 4:35 PM (in response to Newsgroup_User)you don't need evaluate() in your calculation.
<cfset theInstall = myCart[TheIndex][6] * myCart[TheIndex][3] /> will do.
to get the grand total, just loop over myCart performing the calculations.
<cfset grandTotal = 0 />
<cfloop from="1" to="#arrayLen(myCart)#" index="idx">
<cfset grandTotal = grandTotal + (myCart[idx][6] * myCart[idx][3]) />
</cfloop>
<cfoutput>#grandTotal#</cfoutput> 
2. Re: Math Evaluate
Newsgroup_User Dec 7, 2006 4:45 PM (in response to Newsgroup_User)I appreciate your response. But in my quest to learn would you mind telling
me why I don't need the evaluate?
I will give this a try.
Kim
"[CJ]" <webforumsuser@macromedia.com> wrote in message
news:elac13$ft7$1@forums.macromedia.com...
> you don't need evaluate() in your calculation.
> <cfset theInstall = myCart[TheIndex][6] * myCart[TheIndex][3] /> will do.
>
> to get the grand total, just loop over myCart performing the calculations.
> <cfset grandTotal = 0 />
> <cfloop from="1" to="#arrayLen(myCart)#" index="idx">
> <cfset grandTotal = grandTotal + (myCart[idx][6] * myCart[idx][3]) />
> </cfloop>
> <cfoutput>#grandTotal#</cfoutput>
>
>

3. Re: Math Evaluate
Newsgroup_User Dec 7, 2006 4:50 PM (in response to Newsgroup_User)Ok, CJ, the problem I am having is that some installation prices are set to
'0' so, of course when zero is times by anything the answer is zero. Which
wipes out my install total.
Kim
"[CJ]" <webforumsuser@macromedia.com> wrote in message
news:elac13$ft7$1@forums.macromedia.com...
> you don't need evaluate() in your calculation.
> <cfset theInstall = myCart[TheIndex][6] * myCart[TheIndex][3] /> will do.
>
> to get the grand total, just loop over myCart performing the calculations.
> <cfset grandTotal = 0 />
> <cfloop from="1" to="#arrayLen(myCart)#" index="idx">
> <cfset grandTotal = grandTotal + (myCart[idx][6] * myCart[idx][3]) />
> </cfloop>
> <cfoutput>#grandTotal#</cfoutput>
>
>

4. Re: Math Evaluate
Charlie Griefer Dec 8, 2006 11:18 AM (in response to Newsgroup_User)you don't need the evaluate because it's extraneous.
<cfset myValue = 5 * 4 /> < sets myValue to 20
as far as your 0 issue... unless I misunderstood how your structure is set up (my understanding is element 6 is price and element 3 is quantity), it shouldn't matter if price is 0 for a given item. 0 * (whatever the quantity) is 0 for price...but that gets ADDED to the grandTotal value. so if during a given loop iteration, grandTotal is 10.50 and you add 0, you still get 10.50. 
5. Re: Math Evaluate
Newsgroup_User Dec 8, 2006 12:22 PM (in response to Newsgroup_User)That was my thought as well. But it didn't work and I don't know what I was
doing that was wrong so I added a <CFIF TheInstall EQ '0'>that is blank if
its equal to zero, but does the math if it's not.
Kim
"[CJ]" <webforumsuser@macromedia.com> wrote in message
news:elcdpv$f4$1@forums.macromedia.com...
> you don't need the evaluate because it's extraneous.
>
> <cfset myValue = 5 * 4 /> < sets myValue to 20
>
> as far as your 0 issue... unless I misunderstood how your structure is set
> up
> (my understanding is element 6 is price and element 3 is quantity), it
> shouldn't matter if price is 0 for a given item. 0 * (whatever the
> quantity)
> is 0 for price...but that gets ADDED to the grandTotal value. so if
> during a
> given loop iteration, grandTotal is 10.50 and you add 0, you still get
> 10.50.
>