hey... can anyone show me how to calculate sums to the 2nd decimal only? like:
5.50 + 4.00 = 9.50
i seriously have zero idea and could defo use some help...thanks!
5.50 + 4.00 = 9.50
i seriously have zero idea and could defo use some help...thanks!
Code:
<script type="text/javascript"> <!-- function InvoiceSubTotal(form) { var a = (form.assignmentinvoice.value != '') ? eval(form.assignmentinvoice.value) : 0; var b = (form.printinginvoice.value != '') ? eval(form.printinginvoice.value) : 0; var c = (form.shippinginvoice.value != '') ? eval(form.shippinginvoice.value) : 0; form.invoicesubtotal.value = a + b + c; } //--> </script> </head> <html> <body> <label></label> <p> </p> <form id="form" name="form" method="post" action=""> <label> <input name="assignmentinvoice" type="text" id="assignmentinvoice" value="3.36" /> </label> <p> <label> <input name="printinginvoice" type="text" id="printinginvoice" value="8.26" /> </label> </p> <p> <label> <input name="shippinginvoice" type="text" id="shippinginvoice" value="89.22" /> </label> </p> <p> <label> <input type="checkbox" name="checkbox" value="checkbox" onClick="InvoiceSubTotal(this.form);"/> </label> Click to Calculate! </p> <p>Total: <label> <input name="invoicesubtotal" type="text" id="invoicesubtotal" /> </label> </p> </form> <p> </p> </body> </html>
Comment