end if
'如果对象为一个
if not gfIs_ArrayTest(obj) then
if obj.checked = false then
gfGetCheckBoxValue = strValue
exit function
else
gfGetCheckBoxValue = obj.value
exit function
end if
end if
'如果对象为多个
for i = 0 to obj.length - 1
if obj(i).checked = true then
if intCounter > 0 then
strValue = strValue & "^|^" & CStr(obj(i).value)
else
strValue = CStr(obj(i).value)
end if
intCounter = intCounter 1
end if
next
gfGetCheckBoxValue = strValue
end function
上面就是VBScript里面处理复选框的方法(偶用的)。可以把这几个函数封装到一个共通的vbs文件中,并在html的<head>标记区内引用就可以通用了~ 如 <head><script language=vbscript src=vbsChkBoxTool.vbs></script></head>
还要注意一个问题,在实际应用中,有可能根据查询条件生成的一览表里一条记录也没有,就是说没有复选框控件,如果仍旧调用这样一个名字的控件,这时候IE就会报错。没有什么太好的解决办法,于是写了一段程序绕过这个没有复选框控件的情况:
function sIsChkBoxExist()
on error resume next
err.clear
if isEmpty(document.frmOrderList.chkOrder) then
end if
if err.number <> 0 then
else
sIsChkBoxExist=true
end if
err.clear
end function
程序中对预定的控件随便做一个操作,如isEmpty,如果捕捉到了err.number>0的情况,就说明该控件不存在,但由于有on error resume next,所以不会提示错误,这样也就判断出了控件存不存在。
每次在调用上面三个函数之前,先调用一次sIsChkBoxExist函数,看看对应的控件存不存在,这样就不会有错了。
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!



