程序代码
<%
功能:用来在指定CheckBox的哪几个值上打勾
Function CheckBoxScript(ByVal FormElement ByVal ElementValue)
CheckBoxScript = "<scr" & "ipt language=""javascript"" type=""text/Javascript"">" & vbCrLf & "StringPRototype"
CheckBoxScript = CheckBoxScript & "ReallyDo=function(){return thisreplace(/(^s*)|(s*$)/g"""");}" & vbCrLf
CheckBoxScript = CheckBoxScript & "var Jorkin = """ & ElementValue & """split("""");" & vbCrLf
CheckBoxScript = CheckBoxScript & "for (i = ; i < " & FormElement & "length; i++){" & vbCrLf
CheckBoxScript = CheckBoxScript & " for (j = ; j < Jorkinlength; j++){" & vbCrLf
CheckBoxScript = CheckBoxScript & " if (Jorkin[j]ReallyDo() == " & FormElement & "[i]valueReallyDo()){" & vbCrLf
CheckBoxScript = CheckBoxScript & " " & FormElement & "[i]checked = true } } }</scr" & "ipt>" & vbCrLf
End Function
%>
例子:
程序代码
<form name="Form">
<input name="ReallyDo" type="checkbox" id="ReallyDo" value="" />
<input name="ReallyDo" type="checkbox" id="ReallyDo" value="" />
<input name="ReallyDo" type="checkbox" id="ReallyDo" value="" />
<input name="ReallyDo" type="checkbox" id="ReallyDo" value="" />
<input name="ReallyDo" type="checkbox" id="ReallyDo" value="" />
</form>
<%=CheckBoxScript("FormReallyDo"" ")%>