<SCRIPT>
<!-- Activate Cloaking Device
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;
}
// Called by the COMPUTE button; computes and displays the values in the lower table.
function compute()
// computes and displays the unformatted tax value.
var unformatted_tax = (document.forms[0].cost.value)*(document.forms[0].tax.value);
document.forms[0].unformatted_tax.value=unformatted_tax;
// computes and displays the formatted tax value.
var formatted_tax = fmtPrice(unformatted_tax);
document.forms[0].formatted_tax.value=formatted_tax;
// computes and displays the formatted total cost value.
var cost3= eval( document.forms[0].cost.value );
cost3 += eval( (document.forms[0].cost.value)*(document.forms[0].tax.value) );
var total_cost = fmtPrice(cost3);
document.forms[0].total_cost.value=total_cost;
// Called by Reset button - sets original values.
function resetIt()
document.forms[0].cost.value="19.95";
document.forms[0].tax.value=".06";
document.forms[0].unformatted_tax.value="";
document.forms[0].formatted_tax.value="";
document.forms[0].total_cost.value="";
// Called by About button - info on example.
function about()
alert("\nThis is a simple demo of how to format money values to $xx.xx.\n\nEnter different cost & tax values and then click COMPUTE.\n\nThis scheme utilizes the fmtPrice() function by Rolf Howarth.");
// Called by View Source button - displays source of file.
function viewSource()
var current_url="";
current_url=document.location;
window.location="view-source:"+current_url;
// Called by Full Window button - loads file to full window for easy saving.
function WinOpen()
alert('\nPage will load to full screen.\n\nUse View/Document Source from menu bar to view source.\n\nUse File/Save As from menu bar to save.\n\nClose new window to return to this page. ');
window.open("js-money.htm","DisplayWindow","menubar=yes,scrollbars=yes");
window.open("js-money.htm","DisplayWindow","menubar=yes,scrollbars=yes"); // double for Macs
// Deactivate Cloaking -->
</SCRIPT>
</HEAD>
<BODY BGCOLOR=FFFFFF>
<CENTER><STRONG>
<FONT COLOR=blue face=scribble SIZE=+2>想逃税?没门。</FONT>
</STRONG></CENTER>
<CENTER>
<FORM>
<TABLE BORDER=2 WIDTH=300 CELLPADDING=3>
<TR>
<TD align="center"><FONT SIZE=+1><STRONG>商品标价</STRONG></FONT>
<TD align="center"><FONT SIZE=+1><STRONG>税率</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>
<TD align="center"><FONT SIZE=+1><STRONG>绝对税费</STRONG></FONT>
<TD align="center"><FONT SIZE=+1><STRONG>应交税费</STRONG></FONT>
<TD align="center"><FONT SIZE=+1><STRONG>总花费</STRONG></FONT>
<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>
<TABLE BORDER=0 WIDTH=400 CELLPADDING=5>
<TD align="center"><INPUT TYPE="reset" VALUE="复位" onClick="resetIt()">
<TD align="center"><INPUT TYPE="button" VALUE="计算" onclick="compute()">
</TABLE>