<!--#include file= "conn.asp "-->
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> </title>
<link href= "style.css " rel= "stylesheet " type= "text/css ">
<%dim count1
set rs1=server.CreateObject( "adodb.recordset ")
sql1= "select * from lb order by id desc "
rs1.open sql1,conn,1,1
%>
<script language = "JavaScript ">
var onecount;
onecount=0;
subcat = new Array();
<%
count1 = 0
do while not rs1.eof
%>
subcat[ <%=count1%> ] = new Array( " <%= trim(rs1( "mc "))%> ", " <%= trim(rs1( "sj "))%> ", " <%=trim(rs1( "id "))%> ");
<%
count1 = count1 + 1
rs1.movenext
loop
rs1.close
%>
onecount= <%=count1%> ;
function changelocation(locationid)
{
document.form1.stypecode.length = 0;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (i== 0)
{
document.form1.stypecode.options[document.form1.stypecode.length] = new Option( "选择二类 ", " ");
}
if (subcat[i][1] == locationid)
{
document.form1.stypecode.options[document.form1.stypecode.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
</script>
<%dim count2
set rs2=server.CreateObject( "adodb.recordset ")
sql2= "select * from lb order by id desc "
rs2.open sql2,conn,1,1
%>
<script language = "JavaScript ">
var onecount2;
onecount2=0;
subcat2 = new Array();
<%
count2 = 0
do while not rs2.eof
%>
subcat2[ <%=count2%> ] = new Array( " <%= trim(rs2( "mc "))%> ", " <%= trim(rs2( "sj "))%> ", " <%=trim(rs2( "id "))%> ");
<%
count2 = count2 + 1
rs2.movenext
loop
rs2.close
%>
onecount2= <%=count2%> ;
function changelocation2(locationid2)
{
document.form1.stypecode2.length = 0;
var locationid2=locationid2;
var i2;
for (i2=0;i2 < onecount2; i2++)
{
if (i2== 0)
{
document.form1.stypecode2.options[document.form1.stypecode2.length] = new Option( "选择三类 ", " ");
}
if (subcat[i2][1] == locationid2)
{
document.form1.stypecode2.options[document.form1.stypecode2.length] = new Option(subcat2[i2][0], subcat2[i2][2]);
}
}
}
</script>
</head>
<body> <BR> <div align= "center ">
<table width= "638 " border= "0 " cellspacing= "1 " bgcolor= "#FF00FF ">
<form action= "main.asp " name= "form1 " method= "post " >
<%dim rs,sql,selclass
set rs=server.CreateObject( "adodb.recordset ")
%>
<tr bgcolor= "#FFFFFF ">
<td align= "center " width= "134 "> <font size= "2 "> 商品类别 </font> </td>
<td width= "189 "> <font size= "2 "> 一类:
<select name= "btypecode " onChange= "changelocation(document.form1.btypecode.options[document.form1.btypecode.selectedIndex].value) ">
<option value= " "> 选择一类 </option>
<%
sql3= "select * from lb where jb= '1 ' order by id desc "
rs.open sql3,conn,1,1
%>
<option value= " <%=rs( "id ")%> "> <%=rs( "mc ")%> </option>
<%
selclass=rs( "id ")
rs.movenext
do while not rs.eof%>
<option value= " <%=rs( "id ")%> "> <%=rs( "mc ")%> </option>
<%
rs.movenext
loop
rs.close
%>
</select>
</font>
</td>
<td width= "190 "> <font size= "2 "> 二类:
<select name= "stypecode " onChange= "changelocation2(document.form1.stypecode.options[document.form1.stypecode.selectedIndex].value) ">
<option value= " " selected> 选择二类 </option>
<%
sql4= "select * from lb where jb= '2 ' and sj= "&selclass& " order by sj desc "
rs.open sql4,conn,1,1%>
<option value= " <%=rs( "id ")%> " > <%=rs( "mc ")%> </option>
<%
selclass2=rs( "id ")
rs.movenext
do while not rs.eof%>
<option value= " <%=rs( "id ")%> "> <%=rs( "mc ")%> </option>
<%
rs.movenext
loop
rs.close
%>
</select> </font> </td>
<td width= "190 "> <font size= "2 "> 三类:
<select name= "stypecode2 ">
<option value= " " selected> 选择三类 </option> <%
sql4= "select * from lb where jb= '3 ' and sj= "&selclass2& " order by sj desc "
rs.open sql4,conn,1,1%>
<option value= " <%=rs( "id ")%> " > <%=rs( "mc ")%> </option>
<% rs.movenext
do while not rs.eof%>
<option value= " <%=rs( "id ")%> "> <%=rs( "mc ")%> </option>
<%
rs.movenext
loop
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
</select> </font> </td>
</tr>
</form>
</table>
</div>
</body>
</html>
用一个表的三级联动下拉菜单
最新推荐文章于 2024-05-14 14:48:12 发布