谁帮我解决这个问题,我天天膜拜他,vbscript的

来源:百度知道 编辑:UC知道 时间:2024/05/24 13:59:46
我用这个页面求字符串长度,怎么不行啊,高手帮我看看,好像函数错的很厉害
<form id="form1" name="form1" method="post" action="">
<label>
<input name="text" type="text" id="text" />
</label>
<label>
<input name="button" type="button" id="button" value="按钮" onclick="check(a)" />
</label>
</form>
<div id="outPut"></div>

<script language="vbscript">
function check(a)
a=form1.text.value
if len(a)=0 then
b=0
else
b=0
for i = 1 to len(a)

if asc(mid(a,i,1))<0 or asc(mid(a,i,1))>255 then
b=b+2
else
b=b+1
end if
next
end if
b=check
output.innerhtml=b
end function
</script>

你不是就想写这么个东西吗?检测字符串长度
照你的改了
<form id="form1" name="form1" method="post" action="">
<label>
<input name="text" type="text" id="text" />
</label>
<label>
<input name="button" type="button" id="button" value="按钮" onclick="check()" />
</label>
</form>
<div id="outPut"></div>

<script language="vbscript">
function check()
a=form1.text.value

if len(a)=0 then
b=0
else
b=0
for i = 1 to len(a)

if asc(mid(a,i,1))<0 or asc(mid(a,i,1))>255 then
b=b+2
else
b=b+1
end if
next
end if
output.innerhtml=b
end function
</script>