| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 551 人关注过本帖
标题:三级下拉列表互动
只看楼主 加入收藏
luotao
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-5-15
收藏
 问题点数:0 回复次数:0 
三级下拉列表互动

我的数据库有三个表,下面要怎样再加一个下拉列表框,谢谢大家了!
大类:anclass
字段:    数据类型:
anclassid    int
anclass nvarchar
fudongjia int
changyong int
anclassidorder int
中类:nclass
nclassid    int
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[i][1] == locationid)
{
document.myform.Nclassid.options[document.myform.Nclassid.length] = new Option(subcat[i][0], subcat[i][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>

搜索更多相关主题的帖子: int 数据库 列表 互动 changyong 
2006-05-15 23:19
快速回复:三级下拉列表互动
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017122 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved