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" οnchange="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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值