我的一亩三分地 我就喜欢!
13fen  设为主页
 收藏本站
 
当前位置: > 一亩三分地:首页 > 网络学院 > 网络编程 > ASP专区 > Asp数据库/打印 > 省市联动菜单的源代码实现(access数据库版)
热门文章排行
热门文章排行 手推车”功能的实现(10-07)
八大法则防范ASP网站漏洞(10-23)
ASP教程十一、调试ASP脚本(10-23)
在JSP中访问数据库大全(10-23)
虚机服务中常见Asp.Net低级错误一览(03-21)
精采文章排行
精采文章排行 ASP.NET实现抓取网页中的链接(11-15)
ASP连接数据库的11种方法(11-10)
如何动态创建网页的RSS内容摘要(11-10)
ASP网站漏洞及入侵防范方法(11-10)
ASP自定义函数:对字符串正则替换(11-10)
技术专题推荐
网管论坛交流
 

省市联动菜单的源代码实现(access数据库版) 

作者:佚名   来源:一亩三分地   点击:   日期:2007-03-23

在网上经常看到关于联动菜单的贴子,特将自己的代码贴出来,供大学参与.
一.数据库:
表1:Region(ID,Province)
表2:City(ID,City,Province)
二.代码实现:
<!--#include file="Conn.asp"-->
<%
function DbCombox()
dim rs,sql,msg
sql = "select * from Region"
set rs = conn.execute(sql)
while not rs.eof
msg = msg & "<option value=""" & rs("Province") & """>" & rs("Province") & "</option>"
rs.movenext
wend
rs.close
set rs = nothing
DbCombox = msg
End function
%>
<html>

<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>会员登录</title>
</head>

<body>
<script language ="javascript" >
Citys = new Array();
<%
dim rs,sql,i
sql = "select * from City"
set rs = Conn.execute(sql)
i = 0
while not rs.eof
%>
Citys[<%=i%>] =new Array("<%=rs("Province")%>","<%=rs("City")%>");
<%
i = i + 1
rs.movenext
wend
rs.close
set rs = nothing
%>

function changeselect(selvalue){
var selvalue = selvalue;
var i;
document.form1.City.length = 0 ;
document.form1.City.options[document.form1.City.length] = new Option("请选择","");
for (i = 0 ;i <Citys.length;i++){
if(Citys[i][0]==selvalue){
document.form1.City.options[document.form1.City .length] = new Option(Citys[i][1],Citys[i][1]);
}
}
}

document.form1.City.options[document.form1.City.length] = new Option("请选择","");

</script>

<div align="center">
<form method="POST" action="forum.asp" name="form1">
<table border="0" cellpadding="0" style="border-collapse: collapse" width="100%" id="table1" height="59">
<tr>
<td width="67" height="30" bgcolor="#D4D0C8"><b><font size="2">地区</font></b></td>
<td height="30" bgcolor="#D4D0C8"><select size="1" name="Region" onchange ="changeselect(document.form1.Region.options[document.form1.Region.selectedIndex].value)">
<%=DbCombox()%></select></td>
</tr>
<tr>
<td width="67" height="30"><b><font size="2">城市</font></b></td>
<td height="30"><select size="1" name="City"></select></td>
</tr>
</table>
</form>
</div>

</body>

</html>




文章评论】 【收藏本文】 【推荐好友】 【打印本文】 【论坛讨论

   相关文章:
·ASP中巧用Response属性 ·第六课:ASP脚本循环语句
·在 Web 页上使用条件数值格式 ·连接数据库查询手册(不仅仅适用于asp)
·警惕"给你的FileSystemObject对象加把锁" ·用ASP做全文检索

   文章评论:(条)
  
 请留名: 匿名评论   点击查看所有评论 网管论坛
 

  责任编辑:一分  声明:刊登此文章是为了传递更多信息,文章内容仅供参考,转载请注明出处。