资阳大众网租房,:asp如何实现添加产品时分大中小三个类,做成三级联动选择框

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/27 04:09:23
就是三级分类,要做成三级联动式的下拉选择框,选择大类时,出现该大类下的二级分类,选择该二级分类时,出现该二级分类下的三级分类。源代码应包括数据库调用的asp程序。

对不起.时间紧. 给你个二级的. 改改就可以了

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<style type="text/css">
<!--
.style1 { font-size: 14px;
font-weight: bold;
}
-->
</style>
</head>

<body>
<form name="myform1" method="post" action="">
<table width="100%" border="1">
<tr>
<td colspan="2"><div align="center">
<!--#include file="conn.asp"-->

</div>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<div align="center">
<%dim count
set rs=server.createobject("adodb.recordset")
rs.open "select * from xiaolei ",conn,1,1%>
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%= trim(rs("name"))%>","<%= rs("fuleiid")%>","<%= trim(rs("name"))%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>

onecount=<%=count%>;

function changelocation(locationid)
{
document.myform1.Nclassid.length = 0;

var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.myform1.Nclassid.options[document.myform1.Nclassid.length] = new Option(subcat[i][0], subcat[i][2]);
}
}

}
</script>

<table width="100%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#ffffff">
<tr bgcolor="#E8F1FF">
<td width="100%" align="right">
<div align="left"></div>

<div align="left">
<%
rs.open "select * from dalei order by daihao",conn,1,1
if rs.eof and rs.bof then
response.write "无法打开数据库!"
response.end
else
%>
大类:
<select name="anclassid" size="1" id="anclassid" onChange="changelocation(document.myform1.anclassid.options[document.myform1.anclassid.selectedIndex].value)">
<option value="0" selected>==请选择==</option>
<% dim selclass
selclass=rs("id")
do while not rs.eof
%>
<option value="<%=rs("id")%>"><%=trim(rs("name"))%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select>
小类:
<select name="Nclassid">
<%
rs.open "select * from xiaolei where fuleiid="&selclass ,conn,1,1
if not(rs.eof and rs.bof) then
%>
<option selected value="0">==请选择==</option>
<% do while not rs.eof%>
<option value="<%=rs("id")%>"><%=rs("name")%></option>
<% rs.movenext
loop
end if
rs.close
set rs = nothing
%>
</select>
</div></td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="Submit" value="查询">
</div></td>
</tr>
<tr>
<td width="21%"></td>
<td width="79%"></td>
</tr>
</table>
</form>
</body>
</html>