Script Categories













Calculators >>> Tax.

JavaScript helps your to calculate the before and after tax prices for purchases. Very easy to use. Just put into the price, the tax, and hit compute! It's all figured for you!

Cost Tax

Unformatted Tax Formatted Tax TOTAL COST

Add the below code to the <body> section of your page:

<script language="javascript" type="text/javascript">
/* Visit http://www.yaldex.com/ for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin
function fmtPrice(value) {
result="$"+Math.floor(value)+".";
var cents=100*(value-Math.floor(value))+0.5;
result += Math.floor(cents/10);
result += Math.floor(cents%10);
return result;
}
function compute() {
var unformatted_tax = (document.Tax.cost.value)*(document.Tax.tax.value);
document.Tax.unformatted_tax.value=unformatted_tax;
var formatted_tax = fmtPrice(unformatted_tax);
document.Tax.formatted_tax.value=formatted_tax;
var cost3= eval( document.Tax.cost.value );  
cost3
+= eval( (document.Tax.cost.value)*(document.Tax.tax.value) );
var total_cost = fmtPrice(cost3);
document.Tax.total_cost.value=total_cost;
}
function resetIt() {
document.Tax.cost.value="19.95";
document.Tax.tax.value=".06";
document.Tax.unformatted_tax.value="";
document.Tax.formatted_tax.value="";
document.Tax.total_cost.value="";  
}
// End -->
</script>
<FORM name="Tax" id="Tax">
<TABLE BORDER=2 WIDTH=300 CELLPADDING=3>
<TR>
<TD
align="center"><FONT SIZE=+1><STRONG>Cost</STRONG></FONT>
<TD align="center"><FONT SIZE=+1><STRONG>Tax</STRONG></FONT>
</TR>
<TR>
<TD
align="center"><INPUT TYPE="text" NAME="cost" VALUE="19.95" SIZE=10>
<TD align="center"><INPUT TYPE="text" NAME="tax" VALUE=".06" SIZE=10>
</TR>
</TABLE>
<BR>
<TABLE BORDER=1 WIDTH=600 CELLPADDING=3>
<TR>
<TD
align="center"><FONT SIZE=+1><STRONG>Unformatted Tax</STRONG></FONT>
<TD align="center"><FONT SIZE=+1><STRONG>Formatted Tax</STRONG></FONT>
<TD align="center"><FONT SIZE=+1><STRONG>TOTAL COST</STRONG></FONT>
</TR>
<TR>
<TD
align="center"><INPUT TYPE="text" NAME="unformatted_tax" SIZE=15>
<TD align="center"><INPUT TYPE="text" NAME="formatted_tax" SIZE=15>
<TD align="center"><INPUT TYPE="text" NAME="total_cost" SIZE=15>
</TR>
</TABLE>
<BR>
<TABLE BORDER=0 WIDTH=400 CELLPADDING=5>
<TR>
<TD
align="center"><INPUT TYPE="reset"  VALUE="RESET" onClick="resetIt()">
<TD align="center"><INPUT TYPE="button" VALUE="COMPUTE" onclick="compute()">
</TR>
</TABLE>

JavaScript Editor Get Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.



Code was highlighted by 1st JavaScript Editor (The Best JavaScript Editor!).

R7


©