redhobor
发贴: 5
|
于 2005-03-20 08:50
<script language="javascript" type=""> <!-- //Check the total weight of exams and courseworks function calculateWeight() { var weight, weight1, weight2; weight1=document.frm.rst_exmtotalweight.value; weight2=document.frm.rst_cwktotalweight.value; weight=weight1+weight2; if (weight!=100){ window.alert("The total weight of exams and courseworks is not correct!"); document.getElementById("rst_cwktotalweight").focus(); return false; } frm.submit(); } //--> </script> <form name="frm" method="post" action="definemdlstructservlet" onsubmit="return calculateWeight(this);"> <tr bgcolor="#CCCCCC"> <td>How many weight of exams? [100%] </td> <td width="56%" bgcolor="#FFFFFF"> <input type="text" id="rst_exmtotalweight" name="rst_exmtotalweight" value="0" size="5" style="display:none;"> </td> </tr> <tr bgcolor="#CCCCCC"> <td>How many weight of courseworks? [100%] </td> <td width="56%" bgcolor="#FFFFFF"> <input type="text" id="rst_cwktotalweight" name="rst_cwktotalweight" value="0" size="5" style="display:none;"> </td> </tr> </table> <p> </p> <p> <input type="submit" name="Submit" value="Submit"> <input type="reset" name="Reset" value="Reset"> <input type="button" name="back" value="Back" onClick="history.back(-1)"> </p> </form> 为什么我输入数值后,即使相加等于100,仍然会出现错误警告。 如果从数据库得的rst_exmtotalweight和rst_cwktotalweight都是double类型数据,程序需要改进吗? 谢谢!
|