用快捷键来提交按钮,这样比较简单 dn001 2009-06-21 08:35:55 <html> <head> <script language="JavaScript"> //用JS计算您的文胸尺码 网页教学网http://www.knowsky.com function jisuan() { if (document.form1.up.value=='') { alert ('请填入上胸围的尺寸:'); return false; } if (document.form1.up.value=='') { alert ('请填入下胸围的尺寸:'); return false; } var answer=document.form1.up.value-document.form1.under.value; yushu=document.form1.under.value%10; if (yushu < 5) yushu = 0; if (yushu >= 5) yushu = 5; chima='您的文胸尺码为:'+(Math.floor(document.form1.under.value/10)*10+yushu/1); if (answer <= 10) chima=chima+'A'; else if (answer <=14 && answer >=11) chima=chima+'B'; else if (answer <=19 && answer >=14) chima=chima+'C'; else chima=chima+'D'; alert (chima); } </script> </head> <body> <form name="form1" method="post"> 请填入上胸围尺寸: <input name="up" type="text" size="8"> CM <br>请填入下胸围尺寸: <input name="under" type="text" size="8"> CM <br> <input type="submit" name="Submit" value="计算" onclick="jisuan();"> <input type="reset" name="Submit2" value="重填"> </form> </body> </html>