熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

ASP常用函數:CheckBoxScript()

2022-06-13   來源: .NET編程 

  程序代碼

  <%
功能:用來在指定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"" ")%>


From:http://tw.wingwit.com/Article/program/net/201311/14191.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.