问个可能很简单的问题

afoon 2003-12-24 03:21:56
要做两个下拉选择框,前一个选择单位,后一个选择这个单位里的人员,要求前一个选择单位后在后一个选择框内显示这个单位的人员名称,怎样实现比较好一点?
...全文
21 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
DwNet 2003-12-24
  • 打赏
  • 举报
回复
应该比较简单,将数据取出放到数组中.编写JS脚本来控制,当Select列表对象触发onchange事件时取对应数据.
zephyr13 2003-12-24
  • 打赏
  • 举报
回复
简单来说,就是将所有对应信息都放到一个二维数据里,然后在下拉框的onchange事件里配备这个数组的内容
goldworld 2003-12-24
  • 打赏
  • 举报
回复
我有个比较笨的方法,在前一个下拉框里写个onchange事件。后一个下拉框动态查询就可以了,不过这个办法就是要重新刷新页面了
stefli 2003-12-24
  • 打赏
  • 举报
回复
<%@ Language=VBScript %>
<!--#include file="conn.asp"-->
<html>
<head>
<title>连动测试</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<SCRIPT LANGUAGE=javascript>
<!--
var Lineid=new Array(); //线路id
var LineName=new Array(); //线路名称
var LineContent=new Array(); //线路行程
var LinePrice=new Array(); //线路价格

function init(){
<%
i=0
set rs=cn.execute("select * from Line_ZT")
if not rs.eof then
do while not rs.eof
j=0
%>
Lineid[<%=i%>]="<%=trim(rs("id"))%>";
<%
set rs2=cn.execute("select * from Line_ZT where id="&trim(rs("id"))&"")
if not rs2.eof then
%>
LineName[<%=i%>]=new Array()
LineContent[<%=i%>]=new Array()
LinePrice[<%=i%>]=new Array()
<%
do while not rs2.eof
%>
LineName[<%=i%>][<%=j%>]="<%=trim(rs2("LineName"))%>"
LineContent[<%=i%>][<%=j%>]="<%=trim(rs2("LineContent"))%>"
LinePrice[<%=i%>][<%=j%>]="<%=trim(rs2("LinePrice"))%>"
<%
j=j+1
rs2.movenext
loop
end if
rs2.close
set rs2=nothing
i=i+1
rs.movenext
loop
end if
rs.close
set rs=nothing
%>
// 结束查询,建立城市信息数组

if(Lineid.length >0)
{
for(i=0;i<Lineid.length;i++)
with(document.Frm.LineID)
{
options[length]=new Option(Lineid[i],Lineid[i])
document.Frm.LineID.onchange=new Function("go(this.selectedIndex)")
}
}
}

function go(sIndex)
{
for(i=0;i<Lineid.length;i++)
document.Frm.LineName.value=LineName[sIndex-1][0]
document.Frm.LineContent.value=LineContent[sIndex-1][0]
document.Frm.LinePrice.value=LinePrice[sIndex-1][0]
}

window.onload=init
-->
</SCRIPT>
<link rel="stylesheet" href="../website.css" type="text/css">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<form name="Frm" method="post" action="City_List_View.asp" onSubmit="return CheckFrm(this)">
<table width="500" border="0" cellspacing="1" cellpadding="2" align="center" bgcolor="#003333">
<tr bgcolor="#339966">
<td colspan="2" height="20">
<div align="center"><font size="2"><b><font color="#FFFF00">选择线路</font></b></font></div>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="206">
<div align="right"><font size="2">线路标题:</font></div>
</td>
<td width="283"><font size="2">
<select name="LineID" class="background">
<option value="" selected>选择线路编号</option>
</select>
</font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="206">
<div align="right"><font size="2">线路名称:</font></div>
</td>
<td width="283"><font size="2">
<input type="text" name="LineName" class="background">
</font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="206">
<div align="right"><font size="2">线路内容:</font></div>
</td>
<td width="283"> <font size="2">
<textarea name="LineContent" cols="50" rows="5" class="background"></textarea>
</font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="206">
<div align="right"><font size="2">线路价格:</font></div>
</td>
<td width="283"> <font size="2">
<input type="text" name="LinePrice" class="background">
</font></td>
</tr>
</table>
</form>
</body>
</html>
自己研究研究,最好是自己去搜索连动。
swich 2003-12-24
  • 打赏
  • 举报
回复
在论坛搜索“二级联动”
actor2222 2003-12-24
  • 打赏
  • 举报
回复
“搜索”一下,多的是!关键字:联动

28,407

社区成员

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

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