ColdFusion中的循环和

时间:2011-02-16 09:27:40

标签: loops coldfusion sum

我有这个输出:

<cfoutput>#TLFormat((get_ship_row.price[1]*get_ship_row.amount[1])+(get_ship_row.price[2]*get_ship_row.amount[2]))#</cfoutput>

正如您所看到的,我手动添加了两个由id 1和2定义的表达式。我想要的是创建一个将插入此脚本的这些数字的循环,以便更容易实现该功能

1 个答案:

答案 0 :(得分:1)

我怀疑你有点复杂 - 但是如果没有看到更多的代码,很难说。 TLFormat()也是你的自定义功能吗?

但是,如果您循环查询,那么这可能对您有用:

<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>

我希望我能正确理解你的问题。