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

<!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>


拜拜白白
浏览 2757回答 0
0回答
打开App,查看更多内容
随时随地看视频慕课网APP