编程语言
首页 > 编程语言> > asp级联菜单

asp级联菜单

作者:互联网

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Connections/connMenu.asp" -->

<!--打开两个表-->
<%
set rs1=server.CreateObject("adodb.recordset")
sql1="select * from main"
rs1.open sql1,MM_connMenu_STRING,1,3
set rs2=server.CreateObject("adodb.recordset")
sql2="select * from sub"
rs2.open sql2,MM_connMenu_STRING,1,3

%>
<form name="form1">
<!--建立菜单一-->
<select name="mainmenu" size="1" onChange="redirect(this.options.value)">
<option value=0>请选择……</option>
<%while not rs1.eof%>
<option value="<%=rs1("main_id")%>"><%=rs1("main_name")%></option>
<%rs1.movenext
wend%>
</select>
<!--建立菜单二-->
<select name="submenu" size="1">
<option value=0>请选择</option>
</select>

</form>
<!--下面为具体实现的script语句-->
<script>
<!--

var temp=document.form1.submenu
function redirect(x){

var i
i=0
for (var m=temp.options.length-1;m>0;m--)
temp.options[m]=null

<%while not rs2.eof
%>
cnt=<%=rs2("main_id")%>

if(cnt==x) {
temp.options[i]=new Option("<%=rs2("sub_name")%>","<%=rs2("sub_id")%>")
i=i+1}
<%
rs2.movenext
wend%>

}

//-->
</script>

转载于:https://www.cnblogs.com/majinyu/archive/2008/07/30/1256189.html

标签:级联,set,temp,recordset,菜单,asp,var,options,rs2
来源: https://blog.csdn.net/weixin_34129696/article/details/93666463