新微赢技术网

标题: 三级下拉列表互动 [打印本页]

作者: 飘渺    时间: 2010-1-20 00:34
标题: 三级下拉列表互动
我的数据库有三个表,下面要怎样再加一个下拉列表框,谢谢大家了!
大类: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>
作者: 二少    时间: 2010-3-10 21:05
到你的~~贴吧收藏~~~我的发言~`找




欢迎光临 新微赢技术网 (http://bbs.weiying.cn/) Powered by Discuz! X3.2