开发者

Loop sum in ColdFusion

开发者 https://www.devze.com 2023-02-11 13:33 出处:网络
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>

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号