Loop sum in ColdFusion
I have this output:
<cfoutput>#TLFormat((get_ship_row.price[1]*get_ship_row.amount[1])+(get_ship_row.price[2]*get_ship_row.amount[2]))#</cfoutput>
As you can see I manually added two expressions that are defined by id 1 and 2.开发者_JAVA技巧 All I want is to create a loop of these numbers that will be inserted in this script, so that it will be easier to implement the function.
I suspect that you are getting a little convoluted - but it is hard to say without seeing more of your code. Also is TLFormat()
a custom function of yours?
However, if you are looping over a query then this might work for you:
<cfloop from="1" to="#get_ship_row.recordCount - 1#" index="i">
#TLFormat((get_ship_row.price[i]*get_ship_row.amount[i]) + (get_ship_row.price[i+1]*get_ship_row.amount[i+1]))#
</cfloop>
I hope I understood your question correctly.
精彩评论