0

I am trying to add all the values of all the numbers in a list.

So this is what I tried,

<cfloop query="get_total_merchant">
    <cfset tx_amt_total = #tx_amount# + (#tx_amount# * (#merchantFee#/100))>
    #ArraySum(tx_amt_total)#
</cfloop> 

So basically what tx_amt_total will display is something like 1 2 3 4. So I am trying to add 1 + 2 + 3 + 4 which should give me 10.

However, from what I tried, I am getting an error message: Object of type class java.lang.Double cannot be used as an array

So how do I fix my code?

1 Answer 1

5
<cfset tx_amt_total = 0 />

<cfloop query="get_total_merchant">
    <cfset tx_amt_total += (tx_amount + (tx_amount * (merchantFee/100))) />
</cfloop> 

should be enough. You don not need arraySum()

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.