做了一个小程序,比较简单,
我想把得出的最后数值,自动保留小数点后2位,并且四舍五入,
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>油费计算</title>
</head>
<script type="text/javascript">
function account()
{
var a=document.all.a.value;
var b=document.all.b.value;
var c=a/b*100;
document.all.c.value=c;
}
getValue();
</script>
<body>
<form name="form1">
加油数:<input id="a" type="text" >
历程数:<input id="b" type="text" onkeyup="account()">
总和 <input name="" type="text" id="c" maxlength="4">
<input type="button" onclick="account()" value="计算">
</form>
</body>
</html>
相关分类