ASP常用函数:CheckBoxScript()_ASP教程

编辑Tag赚U币
教程Tag:暂无Tag,欢迎添加,赚取U币!

推荐:ASP常用函数:Str4Js()
程序代码 % '功能:定义转换为javascript字符串输出(约定Javascript中,用单引号引用字符串) '来源:http://www.cncms.com/asp.asp Function Str4Js(sString) Str4Js = sString If IsNull(sString) Then Str4Js = : Exit Function Str4Js = Replace(Str4Js, \, \\) Str4J

 程序代码

<%
'功能:用来在指定CheckBox的哪几个值上打勾
'来源:http://www.cncms.com/asp.asp

Function CheckBoxScript(ByVal FormElement , ByVal ElementValue)
  CheckBoxScript = "<scr" & "ipt language=""javascript"" type=""text/Javascript"">" & vbCrLf & "String.PRototype."
  CheckBoxScript = CheckBoxScript & "ReallyDo=function(){return this.replace(/(^\s*)|(\s*$)/g,"""");}" & vbCrLf
  CheckBoxScript = CheckBoxScript & "var Jorkin = """ & ElementValue & """.split("","");" & vbCrLf
  CheckBoxScript = CheckBoxScript & "for (i = 0; i < " & FormElement & ".length; i++){" & vbCrLf
  CheckBoxScript = CheckBoxScript & "  for (j = 0; j < Jorkin.length; j++){" & vbCrLf
  CheckBoxScript = CheckBoxScript & "   if (Jorkin[j].ReallyDo() == " & FormElement & "[i].value.ReallyDo()){" & vbCrLf
  CheckBoxScript = CheckBoxScript & "    " & FormElement & "[i].checked = true } } }</scr" & "ipt>" & vbCrLf
End Function
%>

例子:

 程序代码
<form name="Form1">
<input name="ReallyDo" type="checkbox" id="ReallyDo1" value="10" />10
<input name="ReallyDo" type="checkbox" id="ReallyDo2" value="20" />20
<input name="ReallyDo" type="checkbox" id="ReallyDo3" value="30" />30
<input name="ReallyDo" type="checkbox" id="ReallyDo4" value="40" />40
<input name="ReallyDo" type="checkbox" id="ReallyDo5" value="50" />50
</form>
<%=CheckBoxScript("Form1.ReallyDo","10,30, 50")%>

分享:ASP常用函数:WriteLn() PrintLn()
程序代码 % '功能:输出字符串加换行 '来源:http://www.cncms.com/asp.asp Function WriteLn(sString) Response.Write( sString vbCrLf ) End Function % 程序代码 % '功能:输出字符串加HTML代码br / '来源:http://www.cncms.com/asp.asp Function PRintLn(sString) Res

来源:模板无忧//所属分类:ASP教程/更新时间:2013-05-03
相关ASP教程