[求助]请问二级下拉菜单导航如何读取数据库中分类啊?
普通的导航菜单都只能读取固定的链接,我有2个表,bigclass和smallclass,请问如何制作二级下拉菜单,让菜单中读取数据库中的大类和小类啊?哪位大虾给段代码,谢谢了!!!!
<script language = "JavaScript">
var onecount;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%= trim(rs("SmallClassName"))%>","<%= trim(rs("BigClassName"))%>","<%= trim(rs("SmallClassName"))%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;
function changelocation(locationid)
{
document.addNEWS.SmallClassName.length = 1;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.addNEWS.SmallClassName.options[document.addNEWS.SmallClassName.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
function CheckForm()
{
document. = document.(true);
document.addNEWS.imageNum.value = document.("editImageNum").value;
document.addNEWS.editFirstImageName.value = document.("editFirstImageName").value;
if (document.addNEWS.title.value.length == 0) {
alert("文章标题没有填写.");
document.addNEWS.title.focus();
return false;
}
if (document.addNEWS.user.value.length == 0) {
alert("文章发布人没有填写");
document.addNEWS.user.focus();
return false;
}
return true;
}
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../css.css" type="text/css">
<title>添加文章</title>
<style type="text/css">
<!--
body {
background-color: #ECE9D8;
}
.style1 {
color: #FFFFFF;
font-weight: bold;
}
-->
</style></head>
<body leftmargin="0" topmargin="0" bgcolor="#ECE9D8">
<br>
<table width="65%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#245DDB">
<form name="addNEWS" method="post" action="addinfo_ok.asp" onSubmit="return CheckForm();">
<tr bgcolor="#FFFFFF">
<td height="25" bgcolor="#245DDB"><div align="center" class="style1">文章添加</div></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="25">
<font color="#245DDB">*</font>文章标题:<input name="title" type="text" class="input" size="30"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="25">
<font color="#245DDB">*</font>文章类别:<%
sql = "select * from BigClass"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "请先添加栏目。"
else
%>
<select name="BigClassName" onChange="changelocation(document.addNEWS.BigClassName.options[document.addNEWS.BigClassName.selectedIndex].value)" size="1">
<option selected value="<%=trim(rs("BigClassName"))%>"><%=trim(rs("BigClassName"))%></option>
<%
dim selclass
selclass=rs("BigClassName")
rs.movenext
do while not rs.eof
%>
<option value="<%=trim(rs("BigClassName"))%>"><%=trim(rs("BigClassName"))%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select> <select name="SmallClassName">
<option value="" selected>不指定小类</option>
<%
sql="select * from SmallClass where BigClassName='" & selclass & "'"
rs.open sql,conn,1,1
if not(rs.eof and rs.bof) then
%>
<option value="<%=rs("SmallClassName")%>"><%=rs("SmallClassName")%></option>
<% rs.movenext
do while not rs.eof%>
<option value="<%=rs("SmallClassName")%>"><%=rs("SmallClassName")%></option>
<%
rs.movenext
loop
end if
rs.close
%>
<%
ranNum=int(9*rnd)+10
iddata=month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum
%>
</select></td>
</tr>