用asp,通过数据库,用两个下拉列表框,一个是城市,另一个出现此城市的邮编,选城市时出现相应的地区,怎么实现?

duanfeng 2002-03-08 01:38:16
用asp,通过数据库,用两个下拉列表框,一个是城市,另一个出现此城市的邮编,选城市时出现相应的地区,怎么实现?
...全文
115 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
duanfeng 2002-03-08
  • 打赏
  • 举报
回复
我是Client/ASP(Server)都用JavaScript,怎么修改一下,
却提示RSExecute()什么对象调用错误
yonghengdizhen 2002-03-08
  • 打赏
  • 举报
回复
RS是微软的远程脚本..
浏览器必须支持java applet.
通过远程脚本实现的数据库查询可以不离开当前页面(也就是说java applet工作的不同的线程中)
vspath 2002-03-08
  • 打赏
  • 举报
回复
是很晕,程序太长
duanfeng 2002-03-08
  • 打赏
  • 举报
回复
RSExecute()是什么意思?参数?
nirvana_hg 2002-03-08
  • 打赏
  • 举报
回复
我晕,这么长,看着都头疼。>_<
pukerno3 2002-03-08
  • 打赏
  • 举报
回复
问题不难,但是很烦!
你可以用下拉框的onchange()事件来控制。
flyfox 2002-03-08
  • 打赏
  • 举报
回复
以下是wang_shine(谁派你来的)写的,在哪个贴我忘了,是我保存下来的:
1,我举个例子吧,父类和子类在一个表中
fatherid,childrenid,description 要实现我给你说的联接要求
2, 给页面两个列表框,给出id,如first,second,放在form1中
一个显示父亲类(要在读页面是就显示,asp可以做到,不重复)
3,在页面里包含文件
<SCRIPT LANGUAGE="JavaScript" src="../../_ScriptLibrary/RS.HTM"></script>
<SCRIPT LANGUAGE="JavaScript">RSEnableRemoteScripting("../../_ScriptLibrary")</SCRIPT>
这两个文件其实就是iis创建时的library,注意你的路径,没有的话考一份
4,客户端脚本
function first_onchange()
{
var first_select;
form1.second.innerHTML="";
first_select=form1.first.value;
context = "squaring";
co=RSExecute("getcat.asp","add",first_select);//这句话是调用服务器端的程序的,注意路径
result=co.return_value;//得到服务器传回结果
var option,value,list_array,result,i,;
list_array=result.split("/");
i=0;
form1.second.innerHTML=""; //列表框内清除
//下面就要把 result 进行处理了,假定处理后放在数组list_array[i]里(以 childid,description,childid,description,...存放)
//现在得到list_array[i],要放到 second 列表框中

//
while (list_array[i]!="*")
{
if (list_array[i]!="")
{
if (i%2==1) //奇数项是 description
{
bb.text=list_array[i];
form1.second.add (bb);
}
else
{
bb=document.createElement ("OPTION");////偶数项是 childid

bb.value=list_array[i];
}

}
i=i+1;
} {
bb=document.createElement ("OPTION");
bb.value=list_array[i];

}


服务端程序:
<%@Language=VBScript%>
<%RSDispatch %>//必需的
<!--@CopyWright&Edit by Wang xuejun April,2001--〉
<!--'please pay attention to the path of the folder _scriptlibrary,it should be included in. -->

<!--#INCLUDE FILE="../../_ScriptLibrary/RS.ASP"-->//同客户端
<SCRIPT RUNAT=SERVER LANGUAGE="JavaScript">
var public_description = new MyServerMethods();
function MyServerMethods()
{
this.add = Function( 'value','return add(value)' );//用java声明指向vbscript 函数
}
</SCRIPT>
<SCRIPT RUNAT=SERVER LANGUAGE="VBScript">
Function add(value)//value是传过来的父亲id
dim second,value1,value2
second=""
//下面是从表中根据得到的父类id 把子类找出来
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "cxxxx"
Set Rs= Server.CreateObject("ADODB.Recordset")
sqlText="select childid,description from table where fatherid="&value
Rs.open sqlText,conn,1
while not Rs.eof
second=second&Rs("childid")&"/"&Rs("description")&"/"
Rs.movenext
wend
rs.Close
conn.Close
set rs=nothing
set conn=nothing
add=second&"*"//用*表明数组完毕
End Function
</SCRIPT>
椅子 2002-03-08
  • 打赏
  • 举报
回复
麻烦的要死
我给你个原程序,自己看,没有注释


<%
gwid=request.querystring("id")
gwlc=request.querystring("lc")
'获取公文拟稿信息
sqlstr=swlist(gwid,"1","qy")
set rs=conn.execute(sqlstr)
djnr=rs("djnr")
errorInfo

%>

<script language=javascript>
function checkf()
{
if (document.form1.menu1.selectedIndex=="" || document.form1.menu2.selectedIndex==""|| document.form1.menu1.value=="请选择")
{alert ("false")};
else
{document.form1.cbr.value=group[document.form1.menu1.selectedIndex][document.form1.menu2.selectedIndex].text
alert(document.form1.cbr.value);
}
//document.form1.submit();
}
</script>

</head>
<body topmargin=20 leftmargin=20>
<form name="form1" method="post" action="gw_swdj_post.asp">
<%
sqlstr="select count(*) from xt_dept"
set rs_dept=conn.execute(sqlstr)
count=rs_dept(0)
response.write "<input type='hidden' name='dcount' value='"&count&"'>"
rs_dept.close
set rs_dept=nothing
%>
<input type="hidden" name="cbr">

<select name="menu1" size="1" onChange="redirect(this.options.selectedIndex)">
<option>请选择</option>
<script>
var groups=document.form1.dcount.value;
var group=new Array(groups+1);
for (i=0; i<groups; i++)
group[i+1]=new Array();
for (j=1;j<i+1;j++){
group[j][0]=j;
}
</script>
<%test%>

</select>
<select name="menu2" size="5" multiple>
<option>请选择</option>
</select>
<%
sub test()

str=" select deptid,bmmc from gs_user.xt_dept"
set Rs_dept=conn.execute(str)
if not Rs_dept.eof then
while not Rs_dept.eof
Response.Write "<option value="&Rs_dept("deptid")&">"&Rs_dept("bmmc")&"</option>"
Rs_dept.MoveNext
wend
Rs_dept.close
end if
set rs1=conn.execute(str)
if rs1.eof then
response.end
end if

i=1
response.write "<script>"
while not rs1.eof
bmmc=trim(rs1("bmmc"))
deptid=rs1("deptid")
response.write "group["&i&"][0]='"&bmmc&"';"
str2="SELECT username FROM xt_user WHERE deptid = '"&deptid&"'"
set rs2=conn.execute(str2)
j=1
while not rs2.eof
username=trim(rs2("username"))
response.write "group["&i&"]["&j&"]=new Option('"&username&"','');"
rs2.movenext
j=j+1
wend
rs1.movenext
i=i+1
wend
response.write "function redirect(x){"
response.write "for (m=document.form1.menu2.options.length-1;m>0;m--){"
response.write "document.form1.menu2.options[m]=null;}"
response.write "for (i=0;i<group[x].length;i++){"
response.write "if (x!=0)document.form1.menu2.options[i]=new Option(group[x][i].text,group[x][i].value)}"
response.write "}</script>"
rs1.close

end sub
%>
duanfeng 2002-03-08
  • 打赏
  • 举报
回复
写错了,
用asp,通过数据库,用两个下拉列表框,一个是城市,另一个出现此城市的邮编,选城市时出现相应的邮编,怎么实现?

28,406

社区成员

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

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