问一个联动菜单的问题

aqqzy 2004-10-18 11:50:11
两个下拉列表框,Type1和Type2。

选择Type1的某一项后,Type2显示出相应的项目。

另外,提交后,我想取得Type1和Type2中的两个值。也就是说我想要Type1的ID和Name,Type2的ID和Name。怎么做?

我知道这个问题可能很愚蠢,但我现在遇到了,快点告诉我怎么做吧!!!分不够,我再开贴
...全文
146 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
zc2cm 2004-10-18
  • 打赏
  • 举报
回复
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%= trim(rs("xl"))%>","<%= trim(rs("dl"))%>","<%= trim(rs("id"))%>");
<%
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="jiawz.asp">
<table width="72%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="30%">大类别:</td>
<td width="70%"> <%
sql = "select * from da where xm='"+xm+"'"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "请先添加栏目。"
response.end
else
%> <select name="classid" onChange="changelocation(document.myform.classid.options[document.myform.classid.selectedIndex].value)" size="1">
<option value="<%=trim(rs("id"))%>"><%=trim(rs("mc"))%></option>
<% dim selclass
selclass=rs("id")
rs.movenext
do while not rs.eof
%>
<option value="<%=trim(rs("id"))%>"><%=trim(rs("mc"))%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select> </td>
</tr>
<tr>
<td height="18">小类别:</td>
<td><select name="Nclassid">
<%sql="select * from xiao where xm='"+xm+"' and dl='"+Trim(selclass)+"'"
rs.open sql,conn,1,1
if not(rs.eof and rs.bof) then
%>
<option selected value="<%=rs("id")%>"><%=rs("xl")%></option>
<% rs.movenext
do while not rs.eof%>
<option value="<%=rs("id")%>"><%=rs("xl")%></option>
<% rs.movenext
loop
end if
rs.close
set rs = nothing

%>
</select>
</form>
xiangyyy 2004-10-18
  • 打赏
  • 举报
回复
先在CSDN搜索关键字“联动菜单”
孟子E章 2004-10-18
  • 打赏
  • 举报
回复
你可以放个隐藏的input
<select onchange="x1.value=this.options[this.selectedIndex].value;x2.value=this.options[this.selectedIndex].text">

<input type=hidden name=x1>
<input type=hidden name=x2>
aqqzy 2004-10-18
  • 打赏
  • 举报
回复
那我想取出两个值,怎么办啊!
hqcsx 2004-10-18
  • 打赏
  • 举报
回复
我这个是先选部门,然后选该部门的职务.测试通过.绝对正确.
<%
'取得所有职务
set rsbm=server.createobject("adodb.recordset")
sqlbm="select * from HR_U_job order by Units_id"
rsbm.open sqlbm,cn,3,3
do while not rsbm.eof
if allbm="" then
allbm=mid(rsbm("units_id"),1,3)&"*"&trim(rsbm("job_name"))
else
allbm=allbm&"--"&mid(rsbm("units_id"),1,3)&"*"&trim(rsbm("job_name"))
end if
rsbm.movenext
loop
%>

<script language="JavaScript">
<!--
var bm;
bm="<%=allbm%>";
bm=bm.split("--");

function changedw(locationid)
{
document.form.staff_job_id.length = 0;
document.form.staff_job_id.options[0] = new Option('无职务','');
var i;
for (i=0;i < bm.length; i++)
{
tt=bm[i].split("*");
if(locationid.indexOf(tt[0])>=0){
document.form.staff_job_id.options[document.form.staff_job_id.length] = new Option(tt[1].substring(tt[1].indexOf(".")-1),tt[1]);
}
}
}

//-->
</script>

<td height="25" class="n1" width="78">所在部门</td>
<td height="25" width="125">
<select name="staff_units_id" style="height: 23; width: 108" class="n1" size="1" onchange="changedw(document.form.staff_units_id.options[document.form.staff_units_id.selectedIndex].value)">
<option value="">请选择</option>
<%set rs1=server.createobject("adodb.recordset")
sql="select * from HR_Units order by id"
rs1.open sql,cn,3,3
do while not rs1.eof
%>
<option value="<%=rs1("id")%>"><%=trim(rs1("UnitsName"))%></option>
<%rs1.movenext
loop
rs1.close%>
</select></td>

<td height="25" class="n1" width="71">所在职务</td>
<td height="25" width="160">
<select name="staff_job_id" style="height: 23; width: 127" class="n1" size="1">
<%
if staff_units_id<>"" then
sqldw9="select * from HR_Units where id='"&staff_Units_id&"'"
set rsdw9=cn.execute(sqldw9)
if not rsdw9.eof then temp_Rsxx_Dwstr=trim(rsdw9("id"))
end if

Set rsbm0=Server.CreateObject("ADODB.Recordset")
sqlbm0="select * from HR_U_job where units_id='"&temp_Rsxx_Dwstr&"' order by ID"
rsbm0.open sqlbm0,cn,3,3

do while not rsbm0.eof
%>
<option value="<%=rsbm0("job_id")%>"><%=trim(rsbm0("job_name"))%></option>
<%rsbm0.movenext
loop
rsbm0.close
%>
</select></td>
xxrl 2004-10-18
  • 打赏
  • 举报
回复
http://blog.csdn.net/xxrl/archive/2003/09/03/9950.aspx
celerylhl 2004-10-18
  • 打赏
  • 举报
回复
服务器端代码 嵌套 客户端函数就行,就是说将所有需要的内容都一次读取到客户端,生成相应的函数,需要时就调用

28,391

社区成员

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

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