无法弹出输入数据对话框
实现1+2^2+3^2+...n^2
<head><title>无标题文档</title>
</head>
<body>
<script language="VBScript">
function input()
dim result=0,i,n
n=InputBox("输入一个正整数:")
for i=1 to n
result+=i^i
next
response.Write("结果为:" & result)
end function
</script>
<p><a href=# onclick="input()">输入数字</a></p>
</body>
</html>
<body>
<script language="VBScript">
sub input()
dim result,i,n
resule=0
n=InputBox("输入一个正整数:")
for i=1 to n
result=result+i*i
next
msgbox("结果为:" &result)
end sub
</script>
<br>
<p><a href="#" onclick="input()">输入数字</a></p>
</body>
<head><title>无标题文档</title>
</head>
<body>
<script language="VBScript">
sub input()
dim result,i,n
resule=0
n=InputBox("输入一个正整数:")
for i=1 to n
result=result+i*i
next
msgbox("结果为:" & result)
end sub
</script>
<p><a href="#" onclick="input()">输入数字</a></p>
</body>
</html>
不会VB,用JS写了个,测试通过:
<!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>
<title> new document </title>
<script type="text/javascript">
<!--
function input(){
var num = prompt("请输入你要计算的整数","");
num = num-0;
var result =0;
for (var i=1;i<=num;i++)
{
result += i*i;
}
alert(result);
}
window.onLoad = input();
//-->
</script>
</head>
<body>
</body>
</html>
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息