急啊...为什么下面的程序输不出结果呢?恳请大家指点...

来源:百度知道 编辑:UC知道 时间:2024/07/04 03:12:15
<html>
<head><title>求和</title></head>
<script language="vbscript">
<!--
sub sumtotal_onclick()
dim x,j
x=document.forml.in.value
for j= 1 to x
total = total + j
next
msgbox " 和为 " & total & "。"
end sub
-->
</script>
<body>
<center>
1到x的求和运算
<form name ="form1">
输入x的值:<input type=text name="in"size=3 value=4>
<input type="submit" value="submit" name="sumtotal">
</form>
</center>
</body>
</html>

这句应该是这样,后面是1而不是l:x=document.form1.in.value

forml 打错了,应该是form1.
一字之差呀。

<html>
<head><title>求和</title></head>
<script language="vbscript">
<!--
sub sumtotal_onclick()
dim x,j,total
total=0
x=document.form1.in.value
for j= 1 to x
total = total + j
next
msgbox " 和为 " & total & "。"
end sub
-->
</script>
<body>
<center>
1到x的求和运算
<form name ="form1">
输入x的值:<input type=text name="in" size=3 >
<input type="submit" value="计算" name="sumtotal">
</form>
</center>
</body>
</html>

同时你要允许你的计算机运行脚本