#42004/9/16 21:25:52
<html>
<head><title>字符检查</title>
<script language=vbscript>
sub checkout(str1,str2)
dim chrCnt
ChrCnt = 0
for i = 1 to len(str1)
if mid(str1, i, 1) = str2 then
ChrCnt = ChrCnt + 1
end if
next
alert("字符出现次数" & CStr(ChrCnt))
end sub
</script>
</head>
<body>
<form method="post">
输入一行字符串:<input type="text" name="x1" value=""><br>
输入一个字 符: <input type="text" name="x2" value=""><br>
<input type="button" name="r" value="提交"-
onclick="call checkout(x1.value,x2.value)">
<input type="reset" value="重置">
</form>
</body>
</html>
你的错误是:
for n= 1 to L
c= mid(i,n-1,1)
位置从1开始,而不是0,否则出错
另外
call checkout(x1.value,x2.value)
checkout x1.value, x2.value
另选一种
run at不要写,服务端的程序如ASP,是在服务器里运行程序,把解释好的代码传到客户端。你的代码传到网上去可能要出错。但没有IIS解释可能会忽略掉。
编辑历史:[此帖最近一次被 蓝鲸 编辑过(编辑时间:2004-09-16 21:35:15)]
非常大鱼