asp怎么实现二级联动下拉菜单

rs为一级栏目的记录集

rs2为二级栏目的记录集

分别替换成你自己的记录集名称就好了

<script language="JavaScript">

var onecount;

var count;

onecount=0;

subcat = new Array();

<%

count = 0

do while not rs2.eof

%>

subcat[<%=count%>]=new Array("<%=trim(rs2("eid"))%>","<%= trim(rs2("elm"))%>","<%= trim(rs2("ssyl"))%>");

<%

count = count + 1

rs2.movenext

loop

rs2.close

%>

onecount=<%=count%>;

function changelocation(locationid)

{

document.form1.elm.length = 0;

document.form1.elm.options[document.form1.elm.length] = new Option("请选择二级栏目", "");

var locationid=locationid;

var i;

for (i=0;i < onecount; i++)

{

if (subcat[i][2] == locationid)

{

document.form1.elm.options[document.form1.elm.length] = new Option(subcat[i][1], subcat[i][0]);

}}}

</script>

<form method="POST" name="form1" action="" onSubmit="">

<table width="960">

<tr>

<td width="571" colspan="3">栏目

<select name="ylm" onChange="changelocation(document.form1.ylm.options[document.form1.ylm.selectedIndex].value)" size="1">

<option selected value="">请选择一级栏目</option>

<%

do while not rs.eof

%>

<option value="<%=trim(rs("yid"))%>"><%=trim(rs("ylm"))%></option>

<%

rs.movenext

loop

rs.close

%>

</select> >> <select name="elm" size="1" onchange="lm_true()">

<option selected value="">请选择二级栏目</option>

</select>

<input type="submit" name="button" id="button" value="提交"/>

</table>

<input runat="server" type="hidden" name="MM_insert" value="form1" />

</form>

http://jingyan.baidu.com/article/eae0782788e9d71fec548590.html

原文地址:https://www.cnblogs.com/seasonzone/p/4936405.html