|
我的数据库有三个表,下面要怎样再加一个下拉列表框,谢谢大家了!
大类:anclass
字段: 数据类型:
anclassid int
anclass nvarchar
fudongjia int
changyong int
anclassidorder int
中类:nclass
nclassid int
[知识问答ωωω.χiuGoo.сom]
nclass nvarchar
anclassid int
changyong int
nclassidorder int
小类:
nclassid int
nclass nvarchar
anclassid int
changyong int
nclassidorder int
<%
dim count
set rs=server.createobject("adodb.recordset")
rs.open "select * from shop_Nclass order by Nclassidorder ",conn,3,2%>
<script language = "JavaScript">
var onecount;//定义onecount对象
onecount=0; //初始值为0
subcat = new Array();//subcat对象是一个新的数组
<%
count = 0 '定义count对像初始值为0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%= trim(rs("Nclass"))%>","<%= rs("anclassid")%>","<%= rs("Nclassid")%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;
function changelocation(locationid)
{
document.myform.Nclassid.length = 0;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[1] == locationid)
{
document.myform.Nclassid.options[document.myform.Nclassid.length] = new Option(subcat[0], subcat[2]);
}
}
}
</script>
<form name="myform" method="post" action="saveaddbook.asp?action=add" OnSubmit="return checkkk()" >
<td width="21%" align="right">选择商品的分类:</td>
<td width="79%">
<%
rs.open "select * from shop_anclass order by anclassidorder",conn,3,2
if rs.eof and rs.bof then
response.write "请先添加栏目。"
response.end
else
%>
大类:
<select name="anclassid" size="1" id="anclassid" onChange="changelocation(document.myform.anclassid.options[document.myform.anclassid.selectedIndex].value)">
<option selected value="<%=rs("anclassid")%>"><%=trim(rs("anclass"))%></option>
<% dim selclass
selclass=rs("anclassid")
rs.movenext
do while not rs.eof
%>
<option value="<%=rs("anclassid")%>"><%=trim(rs("anclass"))%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select>
中类:
<select name="Nclassid" >
<%rs.open "select * from shop_Nclass where anclassid="&selclass ,conn,1,1
if not(rs.eof and rs.bof) then
%>
<option selected value="<%=rs("nclassid")%>"><%=trim(rs("nclass"))%></option>
<%
rs.movenext
rs.movenext
do while not rs.eof%>
<option value="<%=rs("nclassid")%>"><%=trim(rs("nclass"))%></option>
<% rs.movenext
loop
end if
rs.close
set rs = nothing
%>
</select> |
|