做了一個小程序,比較簡單,我想把得出的最后數值,自動保留小數點后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>
添加回答
舉報
0/150
提交
取消