<!DOCTYPE html><html><head> <meta charset="UTF-8"> <title></title> <script type="text/javascript"> function math1() { var m=Math.floor(Math.random()*100+1); document.getElementsById("n1").value = m; } function cp() { var r=document.math1.n1.value; if(isNaN(r)==false && r.length!=0) { var C,S; C=2*Math.PI*parseFloat(r); S=Math.round(C*100)/100; doucument.math1.n2.value= C.toFixed(2); doucument.math1.n3.value=C; } else alert("请输入半径,必须为数字"); } </script></head><body> 半径:<input name="n1"type="text" id="n1"><br> 周长:<input name="n2" type="text"><br> 面积:<input name="n3" type="text"><br> <input name="s1" type="button" value="随机按钮" onclick="math1()"> <input name="s2" type="button" value="计算" onclick="cp()"></body></html>
添加回答
举报
0/150
提交
取消