日期:2014-05-16 浏览次数:20462 次
<html> <title>AUTO</title> <head> </head> <body> 价格:<input type=text id="price"><br> 数量:<input type=text id="number"><br> 总和:<input type=text id="sum_money"><br> <script language="javascript"> function calculate() { var ID0=document.getElementById("price"); var ID1=document.getElementById("number"); var ID2=document.getElementById("sum_money"); if(ID0.value!=null&&ID1.value!=null) { var str0=ID0.value; var str1=ID1.value; var exp=/[0-9]/g if(str0.match(exp)&& str1.match(exp)) { if(isNaN((ID0.value)*(ID1.value))) ID2.value="错误输入" else ID2.value=(ID0.value)*(ID1.value) } else ID2.value="错误输入" } if(ID0.value==""||ID1.value=="") ID2.value=""; setTimeout("calculate()",30); } calculate() </script> </body>