关于类别问题 急!

oliver007 2006-11-14 04:04:15
我在一个表单中放有两个<select>下拉框,一个用于从数据库中调出大类编号并在下拉框中列出大类的名称,然后在第二个下拉框中列出该大类下的所有小类的名称,现在我可以在第一个下拉框中列出大类的名称了,可就是不知道怎么根据第一个下拉框所选择的大类名来使第二个下拉框列出该大类下的所有小类?
还请各位多多指教,先谢了!
...全文
121 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
suhui0312 2006-11-14
  • 打赏
  • 举报
回复
<tr>

<td bgcolor="#E3E3E3"> <input name="Product_Id" type="hidden" type="text"
id="Product_Id2" value="<%=iddata%>" size="10" maxlength="10"> <font color="#FF0000">!</font></td>
</tr>
<tr>
<td width="150" height="22" align="right" bgcolor="#C0C0C0">产品名称:</td>
<td bgcolor="#E3E3E3"> <input name="Title" type="text"
id="Title2" size="50" maxlength="80"> <font color="#FF0000">*</font></td>
</tr>
<tr>
<td width="150" height="22" align="right" bgcolor="#C0C0C0">产品简介:</td>
<td> <textarea name="key" cols="56" rows="4"></textarea></td>

</tr>
<tr>
<td width="150" height="22" align="right" valign="middle" bgcolor="#C0C0C0">产品说明:</td>
<td bgcolor="#E3E3E3"> </td>
</tr>
<tr bgcolor="#E3E3E3">
<td colspan="2" align="right" valign="middle"> <div align="left">
<textarea name="Content" style="display:none" rows="1" cols="20"></textarea>
<iframe ID="editor" src="../editor.asp" frameborder=1 scrolling=no width="620" height="405"></iframe>
</div></td>
</tr>
<tr>
<td align="right" bgcolor="#C0C0C0">首页图片:
<input name="IncludePic" type="hidden" id="IncludePic" value="yes"></td>
<td height="96" bgcolor="#E3E3E3"> <input name="DefaultPicUrl" type="text" id="DefaultPicUrl" value="/img/nopic.jpg" size="40" maxlength="120">
<br>
首页的图片,直接从上传图片中选择:
<select name="DefaultPicList" id="select" onChange="DefaultPicUrl.value=this.value;">
<option selected>不指定首页图片</option>
</select> <input name="UploadFiles" type="hidden" id="UploadFiles2">
</td>
</tr>
<tr>
<td width="150" height="22" align="right" bgcolor="#C0C0C0">已通过审核:</td>
<td bgcolor="#E3E3E3"> <input name="Passed" type="checkbox" id="Passed2" value="yes" checked>
是<font color="#0000FF">(如果选中的话将直接发布)</font></td>
</tr>
<tr>
<td height="22" align="right" bgcolor="#C0C0C0">首页显示:</td>
<td bgcolor="#E3E3E3"><input name="Elite" type="checkbox" id="Passed" value="yes">
是<font color="#0000FF">(如果选中的话将在首页做为新产品显示)</font></td>
</tr>
<tr>
<td width="150" height="22" align="right" bgcolor="#C0C0C0">录入时间:</td>
<td bgcolor="#E3E3E3">
<input name="UpdateTime" type="text" id="UpdateTime2" value="<%=now()%>" maxlength="50" size="20">
当前时间为:<%=date%> 注意不要改变格式。</td>
</tr>
<tr>
<td height="10" align="right" bgcolor="#C0C0C0"><div align="left">产品形状;</div></td>
<td bgcolor="#E3E3E3"><select name="xz" id="xz">
<option value="正方形" selected>正方形</option>
<option value="长方形">长方形</option>
</select></td>
</tr>
</table></td>
</tr>
</table>
<div align="center"><p>
<input
name="Add" type="submit" id="Add" value=" 添 加 " onClick="document.myform.action='product_save.asp?action=add';document.myform.target='_self';">
 
</p></div>
</form>
</td>
</tr>
suhui0312 2006-11-14
  • 打赏
  • 举报
回复
<%@language=vbscript codepage=936 %>
<!--#include file="Conn.asp"-->
<!--#include file="Inc/Function.asp"-->
<%
dim rs
dim sql
dim count
set rs=server.createobject("adodb.recordset")
sql = "select * from SmallClass order by SmallClassID asc"
rs.open sql,conn,1,1
%>
<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.myform.SmallClassName.length = 1;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.myform.SmallClassName.options[document.myform.SmallClassName.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}

function CheckForm()
{
if (editor.EditMode.checked==true)
document.myform.Content.value=editor.HtmlEdit.document.body.innerText;
else
document.myform.Content.value=editor.HtmlEdit.document.body.innerHTML;

if (document.myform.Title.value=="")
{
alert("文章标题不能为空!");
document.myform.Title.focus();
return false;
}
if (document.myform.Product_Id.value=="")
{
alert("产品编号不能为空!");
document.myform.Key.focus();
return false;
}
if (document.myform.Key.value=="")
{
alert("关键字不能为空!");
document.myform.Key.focus();
return false;
}
if (document.myform.Content.value=="")
{
alert("文章内容不能为空!");
editor.HtmlEdit.focus();
return false;
}
return true;
}
function loadForm()
{
editor.HtmlEdit.document.body.innerHTML=document.myform.Content.value;
return true
}
</script>
<style type="text/css">
<!--
body {
background-color: #EFEBEF;
}
-->
</style>
<link href="../images/style.css" rel="stylesheet" type="text/css">
<body onLoad="javascipt:setTimeout('loadForm()',1000);">

</td>
</tr>
</table></td>
</tr>
</table></td>
<td width="862" align="center" valign="top">
<br>
<br>
<center>
<b>添加产品展示信息</b>
</center>
<br>
<br>
<br>
<form method="POST" name="myform" onSubmit="return CheckForm();" action="ArticleSave.asp?action=add" target="_self">
<table width="620" border="0" align="center" cellpadding="0" cellspacing="0" class="border">
<tr>
<td height="20" align="center" class="title"> </td>
</tr>
<tr align="center">
<td class="tdbg"> <table width="100%" border="0" cellpadding="0" cellspacing="2">
<tr>
<td width="150" height="22" align="right" bgcolor="#C0C0C0">所属类别:</td>
<td bgcolor="#E3E3E3">
<%
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.myform.BigClassName.options[document.myform.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" type="hidden">
<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>

</table>


给你一段代码,自己研究一下吧
lailuboy 2006-11-14
  • 打赏
  • 举报
回复
daxuejianku(无言的悲伤) 的正解。
夜的眼2021 2006-11-14
  • 打赏
  • 举报
回复
js
北京不不 2006-11-14
  • 打赏
  • 举报
回复
如果不用刷新页面。建议用ajax.
如果你可以刷新页面.不就简单..在大类前加个onchange事件...提交表单..
然后或得第一个值...根据第一个值取二级菜单..把一级菜单值传回去..
你也是两角.自己应该会写.如果用AJAX...CSDN里有很多..
stou 2006-11-14
  • 打赏
  • 举报
回复
up too
oliver007 2006-11-14
  • 打赏
  • 举报
回复
自己顶,急

28,391

社区成员

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

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