想要根据框中键入的数字在canvas中循环画图,不知道为什么循环不了呢?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>

<script type="text/javascript">
function block(){
    var height = document.myFrom.txtcount.value;
    var c = document.getElementById("myCanvas");
    var cxt = c.getContext("2d");
    
     for(i = 0; i < height; i++){
        cxt.fillStyle="#FF0000";
        cxt.fillRect(0,0+i*150,150,75);
        
        cxt.fillStyle="#ffffff";
        cxt.beginPath();
        cxt.arc(70,18+i*150,15,0,Math.PI*2,true);
        cxt.closePath();
        cxt.fill();
    }
}
</script>
</head>

<body>

<from name = "myFrom">
    <input type="text" name="txtcount"/>
    <input type="submit" name = "Submit" value="Go!" / onclick="block">
</from>

<canvas id="myCanvas" width="150" style="border:1px solid #c3c3c3;">Your browser does not support the canvas element.</canvas>

</body>

</html>


qq_伽利略扭秤_0
浏览 2021回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP