<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="javascript">
?function roundFun(numberRound,roundDigit) //四舍五入,保留位數(shù)為roundDigit ,供計(jì)算時(shí)用
? {
?? if (numberRound>=0)
?? {
???var tempNumber = parseInt((numberRound * Math.pow(10,roundDigit)+0.5))/Math.pow(10,roundDigit);
???return tempNumber;
??}
??else
?? {
???numberRound1=-numberRound
???var tempNumber = parseInt((numberRound1 * Math.pow(10,roundDigit)+0.5))/Math.pow(10,roundDigit);
???return -tempNumber;
??}
???? }
</script>
<title>Test</title>
</head>
<form name="form1">
<input name="num1" type="text" id="num1" maxlength="10">
<input type="button" name="Submit" value="Click Me" onclick="javascript:this.form.num1.value=roundFun(this.form.num1.value,2)">
</form>
</body>
</html>
?