2级联动

asp

2008-05-26 13:01

<!-- 二级联动菜单 开始 -->
<script language="JavaScript">
<!--
<%
'二级数据保存到数组
Dim count2,rsClass2,sqlClass2
set rsClass2=server.createobject("adodb.recordset")
sqlClass2="select * from web_fenlei where fuid=0"
rsClass2.open sqlClass2,conn,1,1
%>
var subval2 = new Array();
//数组结构:一级根值,二级根值,二级显示值
<%
count2 = 0
do while not rsClass2.eof       '1级 菜单RS

sql="select * from web_fenlei where fuid="&rsClass2("id") '根据1级取2级
set rs123=conn.execute(sql)
if not rs123.eof then
do while not rs123.eof
%>

subval2[<%=count2%>] = new Array('<%=rsClass2("dalei")%>','<%=rs123("dalei")%>','<%=rs123("dalei")%>')


<%
count2 = count2 + 1
rs123.movenext
loop

else
%>
subval2[<%=count2%>] = new Array('<%=rsClass2("dalei")%>','没有分类!','没有分类!')

<%
count2 = count2 + 1
end if

rsClass2.movenext
loop
rsClass2.close
%>


function changeselect1(locationid)
{
document.form2.lb2.length = 0;
//document.form2.lb2.options[0] = new Option('==请选择类别==','');

for (i=0; i<subval2.length; i++)
{
if (subval2[i][0] == locationid)
{document.form2.lb2.options[document.form2.lb2.length] = new Option(subval2[i][2],subval2[i][1]);}
}
}

//-->
</script>

<select name="lb" id="lb" onChange="changeselect1(this.value)">
<option value="99999">==请选择频道==</option>
<% ASP 1级%>
</select>

<select name="lb2" id="lb2">
<option value="99999">==请选择频道==</option>
</select>