»
EnglishFrenchVietnamese

Print - CSUM - JavaScriptBank.com

Full version: jsB@nk » Calculation » CSUM
URL: http://www.javascriptbank.com/csum.html

CSUM © JavaScriptBank.comA function to sum input boxes and display in text rounded to two places with dollar sign. It also sends result with submit and has a reset.

Full version: jsB@nk » Calculation » CSUM
URL: http://www.javascriptbank.com/csum.html



JavaScript
<SCRIPT language=JavaScript><!-- Another function by Ira --><!-- Original Programmed by Ira Sterbakov - irasterb@erols.com 5/13/05 --><!-- Please keep credit in script --><!-- May be freely used and modified - email notification would be nice -->function csum(){var tsum=0;for ( i1 = 1; i1 < 7; i1++ ){k = "i" + i1;tsum += document.getElementById(k).value/1;}tsum = Math.floor((tsum + .005)*100)/100;document.getElementById("s1").value = "$" + tsum;document.getElementById("d1").innerHTML = "<b><font size=+1>TOTAL: $" + tsum + "</font></b>";}function csumr(){document.Istup.reset();document.getElementById("s1").value = " ";document.getElementById("d1").innerHTML = " ";}</SCRIPT><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<FORM name=Istup action=mailto:You@yours.com?subject=CSUM method=post encType=text/plain><TABLE cellPadding=4 forder="0" align=center>  <TBODY>  <TR>    <TD align=right><B>FIRST:</B></TD>    <TD><B><INPUT id=a1 onchange=csum(); name=i1 width="10"><BR></B></TD>  <TR>    <TD align=right><B>SECOND:</B></TD>    <TD><B><INPUT id=a2 onchange=csum(); name=i2 width="10"><BR></B></TD>  <TR>    <TD align=right><B>THIRD:</B></TD>    <TD><B><INPUT id=a3 onchange=csum(); name=i3 width="10"><BR></B></TD>  <TR>    <TD align=right><B>FOURTH:</B></TD>    <TD><B><INPUT id=a4 onchange=csum(); name=i4 width="10"><BR></B></TD>  <TR>    <TD align=right><B>FIFTH:</B></TD>    <TD><B><INPUT id=a5 onchange=csum(); name=i5 width="10"><BR></B></TD>  <TR>    <TD align=right><B>SIXTH:</B></TD>    <TD><B><INPUT id=a6 onchange=csum(); name=i6 width="10"><BR></B></TD>  <TR>    <TD></TD>    <TD><INPUT id=s1 type=hidden name=Total width="10">       <DIV id=d1> </DIV><BR><INPUT type=submit value=Submit> <INPUT onclick=csumr(); type=button value=Reset></TD></TR></TBODY></TABLE></FORM><P align=center>Another application by <A href="mailto:irasterb@erols.com?subject=CSUM"><FONT color=#0000ff>Ira</FONT></A>.<!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->