先选择大类再选择小类的问题?

lula 2005-11-24 04:44:48
有两个下拉选框,大类selectclass_parnet和小类selectclass_child,我想选择大类之后,根据选择的大类从数据库中读出小类内容填入小类选框中?
...全文
166 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
yangxuhua 2006-01-12
  • 打赏
  • 举报
回复
<%
t=request.QueryString("t")
if t=1 then
sql = "select * from BigClass where bigclassname='产品中心'"
else
sql = "select * from BigClass where bigclassname='新闻中心'"
end if
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>


<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]);
}
}
}
</script>
crore 2005-11-24
  • 打赏
  • 举报
回复
http://www.MicroSystem.cn/data/provinceCitySelect3.htm
http://www.MicroSystem.cn/data/provinceCitySelect4.htm
http://www.MicroSystem.cn/data/provinceCitySelect5.htm
看看这个应该有用的!
注意原代码
竹林听雨2005 2005-11-24
  • 打赏
  • 举报
回复
<table width="218" height="250" border="0" cellpadding="1" cellspacing="1" class="tdlrd">
<tr>
<td align="center" valign="middle" bgcolor="#FFFFFF">
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF">
<form method="post" action="search.asp" name="search">
<tr bgcolor="#F7f7f7">
<TD align=center> </TD>
<TD width="66%" align=center>
<table border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="140" align="left"> <script language="JavaScript">
<!--
var onecount;
subcat = new Array();
subcat[0] = new Array("经理","1","1");
subcat[1] = new Array("助理","1","2");
subcat[2] = new Array("技术员","1","3");
subcat[3] = new Array("销售员","1","4");
subcat[4] = new Array("系统分析员","2","5");
subcat[5] = new Array("软件工程师","2","6");
onecount=6;

function changelocation(locationid)
{

document.search.typeid2.length = 0;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.search.typeid2.options[document.search.typeid2.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
if (document.search.typeid2.length == 0){
document.search.typeid2.options[document.search.typeid2.length] = new Option("无子类", "");
}
}
//-->
</script> <select name="szhiwei" style="WIDTH: 140px" onChange="changelocation(document.search.szhiwei.options[document.search.szhiwei.selectedIndex].value)">
<OPTION value="" selected>不限制类别</OPTION>
<option value="1">计算机</option>
<option value="2">学生</option>
</select> <input type=hidden value=不限 name=ckey2></td>
</tr>
</table></TD>
</tr>
<tr bgcolor="#F7f7f7">
<TD height="28" align=center class=zi> </TD>
<TD align=center class=zi>
<select name="typeid2" id="typeid2" style="width:140">
<option value="" selected>不限制</option>
</select></TD>
</tr>
</table>


你将小类的代码换一下就可以实现了。

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧