Binding 从cfc对窗体内的绑定字段求和

Binding 从cfc对窗体内的绑定字段求和,binding,coldfusion,sum,cfc,Binding,Coldfusion,Sum,Cfc,我需要计算一张发票的总数。此发票是使用表单、金额、数量和税务字段创建的,这些字段的总和是通过绑定cfinput生成的。 我无法计算所有行的总数。 我尝试了一些操作,但没有找到解决方案 这是一个示例代码: <cfform action="" method="post"> <cfloop from="1" to="3" index="i"> Q.ta <cfinput type="text" name="quantita#i#" value="0">

我需要计算一张发票的总数。此发票是使用表单、金额、数量和税务字段创建的,这些字段的总和是通过绑定cfinput生成的。 我无法计算所有行的总数。 我尝试了一些操作,但没有找到解决方案

这是一个示例代码:

<cfform action="" method="post">
<cfloop from="1" to="3" index="i">

    Q.ta <cfinput type="text" name="quantita#i#" value="0"> 
    + 
    Importo <cfinput type="text" name="importo#i#" value="0"> 
    +
    Tax <cfinput type="text" name="iva#i#" value="0"> 
    = 
    Totale <cfinput type="text" name="totale#i#" value="0" bind="cfc:somma.getSomma({quantita#i#},{importo#i#},{iva#i#})">

    <br /><br />        

</cfloop>

Q.ta
+ 
重要的
+
税
= 
总计


氟氯化碳:



我认为如果您想循环所有这些表单字段并获得“总计”,您需要创建一个Javascript函数。我的建议是放弃cfform,使用jQuery创建一个可编辑的网格。

好的,我找到了解决方案,我使用cfdiv作为总计:

<cfparam name="var_tot" default="0">

<cfloop from="1" to="3" index="i">
<cfparam name="totale#i#" default="0">
<cfset var_tot = listappend(var_tot, "{totale"&#i#&"}")>
</cfloop>



<cfform action="" method="post">
<table>
<cfloop from="1" to="3" index="i">
<tr>    
    <td>Q.ta</td><td><cfinput type="text" name="quantita#i#" value="0"></td>  
    <td>Importo</td><td><cfinput type="text" name="importo#i#" value="0"> </td>
    <td>Tax</td><td><cfinput type="text" name="iva#i#" value="0"> </td>
    <td>Totale</td><td class="price"><cfinput type="text" name="totale#i#" value="0" bind="cfc:somma.getSomma({quantita#i#},{importo#i#},{iva#i#})" ></td>      
</tr>
</cfloop>
</table>
</cfform>

<cfdiv bind="url:divtot.cfm?InputText=#var_tot#" id="checktot">

Q.ta
重要的
税
总计
divtot.cfm

<cfparam name="tot" default="0">
<cfset listval=url.InputText>

<cfloop index="i" list="#listval#" delimiters=",">
<cfset tot=tot+i>
</cfloop>


TOTALE: <cfoutput>#tot#</cfoutput>

总计:#总计#
谢谢大家

我已经放弃使用jQuery验证器了。没有回头看。。。
<cfparam name="tot" default="0">
<cfset listval=url.InputText>

<cfloop index="i" list="#listval#" delimiters=",">
<cfset tot=tot+i>
</cfloop>


TOTALE: <cfoutput>#tot#</cfoutput>