直接show 直接show

<html>
<head>
<meta charset="big5"/>
<title>Ch6_4_4.htm</title>
</head>
<body>
<h2>測試do while迴圈</h2>
<hr/>
<script>
var i = 1;
var intSum = 0;
do {
   document.write("整數: " + i + "<br/>");
   intSum += i;
   i++;
} while (i <= 18);
document.write("<hr/>總和: " + intSum + "<br/>");
</script>
</body>
</html>
 

草稿一 草稿一

<html>
<head>
<meta charset="big5"/>
<title>Ch6_4_4.htm</title>
</head>
<body>
<h2>測試do while迴圈</h2>
<hr/>
<script>
var i = 1;
var intSum = 0;
do {
   document.write("整數: " + i + "<br/>");
   intSum += i;
   i++;
} while (i <= 18);
document.write("<hr/>總和: " + intSum + "<br/>");
</script>
<input type="button"value="click!!click me"onclick="showmessage()">
</body>
</html>
 

按鈕 按鈕

<html>

<head>
<meta charset="big5"/>
<title>Ch6_4_4.htm</title>
</head>
<body>
<h2>測試do while迴圈</h2>
<hr/>
<script>
function showmessage()
{
var i = 1;
var intSum = 0;
var loop=0;
loop=document.myform.aaa.value;
do {
document.write("整數: " + i + "<br/>");
intSum += i;
i++;
} while (i <= loop);
document.write("<hr/>總和: " + intSum + "<br/>");
}
</script>
<form name="myform">
<input type="number" name="aaa" value=3>
<input type="button" value="click!!click me"onclick="showmessage()">
</form>
</body>
</html>