同时更新3个下拉列表数据的标单怎么处理

tanweish 2005-05-17 10:32:49
有三个表,分别捆绑了3个下拉列表:
CREATE TABLE [dbo].[City] (
[id] [int] IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL ,
[CityName] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[CityId] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[AreaId] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[DepartmentId] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]

CREATE TABLE [dbo].[Area] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[AreaName] [varchar] (30) COLLATE Chinese_PRC_CI_AS NULL ,
[departmentid] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[Areaid] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]

CREATE TABLE [dbo].[Department] (
[id] [int] IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL ,
[DepartmentId] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[DepartmentName] [varchar] (40) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]

1、现在是要选取CITY捆绑的下拉列表后,area的捆绑内容随city的变化而变化,department 的内容也变化
2、选取area后,department 的内容随着变化

...全文
63 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
SuperBJack 2005-05-17
  • 打赏
  • 举报
回复
我介绍个好方法你参考下:


<iframe name="IFR" marginheight="22" marginwidth="520" height="22" width="520" frameborder="0" src="pvct.asp"></iframe>

嵌入pvct.asp这个页面是联动的选择框.

----pvct.asp-----------
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="COMAS.CSS">
<body topmargin="0" leftmargin="0" bgcolor="#F2F2F2">
<!--#include file="ADOFunction.asp"-->
<%
call myConn("XXXXX.mdb")
dim strSQL,objRS
dim prov,city,selck,revalue
prov=request("prov")
city=request("city")
%>
<form name="form1" action="pvct.asp" method="post" >
<table width="520" cellpadding="0" cellspacing="0" >
<!--DWLayoutTable-->
<TR height="21">
<TD width="520" height="21" valign="top">
<select name="prov" onChange="myact(this)" class="kang2">
<%
if prov<>empty then
response.write"<option value='"&prov&"'>"&prov&"</option>"
else
response.write"<option value=''>选择省</option>"
end if
strSQL = "SELECT tprov FROM tprov"
set objrs=myRecord(strSQL,"tprov")
do while not objRS.EOF
response.Write"<option value='"&objRS("tprov")&"'>"&objRS("tprov")&"</option>"
objRS.movenext
loop
objRS.close
set objRS=Nothing
%>
</select> <select name="city" onChange="myact(this)" class="kang2">
<%
if city=empty then
response.write"<option value=''>选择市</option>"
else
response.write"<option value='"&request("city")&"'>"&request("city")&"</option>"
end if
strSQL = "SELECT *FROM tcity Where tprov='" & prov & "'"
set objrs=myRecord(strSQL,"tcity")
do while not objrs.eof
response.Write"<option value='"&objrs("tcity")&"'>"&objrs("tcity")&"</option>"
objrs.movenext
loop
objrs.close
set objrs=nothing
%>
</select> <input type="hidden" name="selck" id="selck"> </TD>
<TD width="1"> </TD>
</TR>
</table>
</form>
<script language="JavaScript">
<!--
function myact(t){
if(t.name=="prov"){
//document.form1.selck.value=document.form1.prov.value
parent.document.form1.prov.value=document.form1.prov.value
parent.document.form1.city.value=""
document.form1.city.value=""
document.form1.submit();
}
if(t.name=="city" ){
parent.document.form1.city.value=document.form1.city.value
}

}
-->
</script>
gzwuyh 2005-05-17
  • 打赏
  • 举报
回复
city_send.asp
*****************************************
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>值传送</title>
</head>

<body>
<%dim connstr,conn,rs,sql
connstr=_
"Provider=SQLOLEDB.1;" _
& "Password=111111;" _
& "Persist Security Info=True;" _
& "User ID=sa;" _
& "Initial Catalog=test;" _
& "Data Source=192.168.1.60;" _
& "Connect Timeout=15"

set conn=server.createobject("adodb.connection")
set rs=server.createobject("adodb.recordset")
conn.open connstr
change_type=trim(request.querystring("change_type"))
id=trim(request.querystring("id"))
%>

<script language=javascript>
var city_data=new Array();


<%
sql="select * from city where pid="&id
'response.write sql
rs.open sql,conn,1,1
city_count=0
do while not rs.eof
%>
city_data[<%=city_count%>]=new Array("<%=rs(0)%>","<%=rs(1)%>");<%rs.movenext
city_count=city_count+1
loop
rs.close
conn.close
set rs=nothing
set conn=nothing
%>
parent.city_dataset('<%=change_type%>',city_data);
</script>
</body>
</html>
***************************************************************
表city字段id,cityname,pid即数据如下.

"id","cityname","pid"
1,"贵州",0
2,"河北",0
3,"贵州1",1
4,"贵州2",1
5,"河北1",2
6,"河北2",2
7,"贵州1-1",3
8,"贵州1-2",3
9,"贵州2-1",4
10,"贵州2-2",4
11,"河北1-1",5
12,"河北1-2",5
13,"河北2-1",6
14,"河北2-2",6
15,"贵州1-1-1",7
16,"贵州1-1-2",7
17,"贵州1-1-1-1",15
18,"贵州1-1-1-2",15
19,"贵州1-1-1-1-1",17
20,"贵州1-1-1-1-2",17


gzwuyh 2005-05-17
  • 打赏
  • 举报
回复
看下面的,自动展开下级下下级数据,选择省,自动展开城市以下级的数据,选择城市自动展开乡以下级的数据.

city.asp
****************************************************************************
<form name="form1">
省份<select name="sheng" onchange="city_change(this.name,this.value)">
<%
sql="select * from city where pid=0"
rs.open sql,conn,1,1
do while not rs.eof
%>
<option value="<%=rs(0)%>"><%=trim(rs(1))%></option>
<%
rs.movenext
loop
%>
</select>
城市:<select name="city" onchange="city_change(this.name,this.value)">
</select>
乡:<select name="xiang" onchange="city_change(this.name,this.value)">
</select>

村:<select name="chun" onchange="city_change(this.name,this.value)">
</select>
寨:
<select name="zhai" onchange="city_change(this.name,this.value)">
</select>
门号:
<select name="cardNO">
</select>
</form>
<iframe src="about:blank" width=0 height=0 name="city_url"></iframe>
<script language=javascript>

function city_change(change_type,id)
{
if(change_type!="cardNO") //如果是最后一级则不在往下
{window.city_url.location.href="city_send.asp?change_type="+change_type+"&id="+id;
}
}
function city_dataset(change_type,city_data)
{

var city_id=form1.elements;
var select_city;
var f=0;
for(k=0;k<city_id.length;k++) //清除本级以下的数据
{
if(city_id[k].tagName=="SELECT" && f!=0)
{
city_id[k].options.length=0;
}

if(city_id[k].tagName=="SELECT" && city_id[k].name==change_type)
{
select_city=city_id[k+1];
f=1;
}
}

for(k=0;k<city_data.length;k++)
{
select_city.options.length=select_city.options.length+1;
select_city.options[select_city.options.length-1].value=city_data[k][0];
select_city.options[select_city.options.length-1].text=city_data[k][1];
}
if(select_city.options.length>0) //自动展开下级下下级数据
{
city_change(select_city.name,select_city.options[0].value);
}

}
city_change("sheng",form1.sheng.options[0].value);
</script>

28,408

社区成员

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

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