binding - sum the fields of the bind inside a form, from cfc -
i need calculate total of invoice. invoice created form, amount, quantity , tax fields, sum of fields made bind in cfinput. can not make sum of rows, total. tried operations, not arriving @ solution
this example code:
<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>
cfc:
<cfcomponent> <cffunction name="getsomma" access="remote" returntype="string"> <cfargument name="quantita" default="0"> <cfargument name="importo" default="0"> <cfargument name="iva" default="0"> <cfset totalesomma=#evaluate((importo*quantita)*(1+iva))#> <cfreturn totalesomma> </cffunction> </cfcomponent>
i think need create javascript function if want loop through these form feilds , "grand total". suggestion abandon cfform , use jquery create editable grid.
Comments
Post a Comment