为了账号安全,请及时绑定邮箱和手机立即绑定

随机产生半径(1~100之间),然后再计算圆的周长与面积函数 。这段代码为什么运行不了

随机产生半径(1~100之间),然后再计算圆的周长与面积函数 。这段代码为什么运行不了

拜拜白白 2016-10-16 11:56:59
<!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 回答
  • 0 关注
  • 2756 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信