Steven,
The arrayappend function doesn't like the clicks_per_product.click[i],
it's treating it as a Boolean value and I'm not sure why when it is
actually a number.
Ben
-----Original Message-----
From: DURETTE, STEVEN J (AIT) [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 19, 2003 12:08 PM
To: CF-Talk
Subject: RE: Array Sum
Ben,
First, you should be creating the array outside of the loop. Next, you
are
always displaying the sum of the current position of the array not a sum
of
the whole array.
I think that this should work better.
<code>
<cfset prodLinkTotal = arrayNew(1)>
<cfloop from="1" to="#clickCount#" index="i">
<cfset prodLinkTotal = arrayAppend(prodLinkTotal,
clicks_per_product.click[i])>
</cfloop>
<cfoutput>#arraySum(prodLinkTotal)#</cfoutput>
</code>
Steve
-----Original Message-----
From: Ben Densmore [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 19, 2003 11:51 AM
To: CF-Talk
Subject: Array Sum
Can someone tell me why this won't work correctly. I have the following
code
<code>
<cfloop from="1" to="#clickCount#" index="i">
<cfset prodLinkTotal = ArrayNew(1)>
<cfset prodLinkTotal[i] = clicks_per_product.click[i]>
<cfoutput>#ArraySum(prodLinkTotal[i])#</cfoutput>
</cfloop>
</code>
Rightnow the clickcount is at 4 so if I output just prodLinkTotal[i] I
get the total number of clicks for each product(303 289 95 89). I now
need to add these up and thought ArraySum() would do it but I keep
getting this error:
Object of type class java.lang.Integer cannot be used as an array
Is there a better way to accomplish this?
Thanks,
Ben
_____
_____
[Todays Threads]
[This Message]
[Subscription]
[Fast Unsubscribe]
[User Settings]
- Array Sum Ben Densmore
- RE: Array Sum Philip Arnold
- RE: Array Sum DURETTE, STEVEN J (AIT)
- RE: Array Sum Ben Densmore
- RE: Array Sum Patricia G. L. Hall
- RE: Array Sum Ben Densmore
- RE: Array Sum Ben Densmore