Maison >interface Web >tutoriel HTML >html实现阶乘,为什么不对,大神们帮我看看_html/css_WEB-ITnose
计算∑N! | |
输入整数N的值: | |
∑N!= | |
<html ><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>项目3</title></head><style type="text/css">.div{background-color:#339966;width:700px;height:250px;margin:0 auto;border:20px groove #4CBE4C;}.STYLE1 {color: #FFFFFF;font-weight: bold;font-size: 24px;}</style><body><script type="text/javascript"> function js(){ var n = parseInt(document.getElementById("N").value)||0; var r=1; for (i=1;i<=n;i++){r*=i;} document.getElementById("sum").value=r }</script><div class="div"> <form id="form3" name="form3" method="post" action=""> <table width="700" border="0" align="center"> <tr> <td height="50" colspan="2"><p align="center" class="STYLE1" >计算∑N!</p></td> </tr> <tr> <td height="50" class="STYLE1"><div align="center">输入整数N的值:</div></td> <td height="50"> <label> <input type="text" name="N" id="N" /> </label> </td> </tr> <tr> <td height="50" class="STYLE1"><div align="center">∑N!=</div></td> <td height="50"> <label> <input type="text" name="sum" id="sum" /> </label> </td> </tr> <tr> <td height="50"> <label> <div align="center"> <input type="submit" name="Submit" value="计算∑N!" onClick="js();return false;"/> </div> </label></td> <td height="50"> <label> <div align="center"> <input type="reset" name="Submit2" value="清空" /> </div> </label> </td> </tr> </table> </form> </div></body></html>