省市聯動菜單的原始碼實現(access資料庫版)

來源:互聯網
上載者:User
access|菜單|聯動菜單|資料|資料庫|原始碼 在網上經常看到關於聯動菜單的貼子,特將自己的代碼貼出來,供大學參與.
一.資料庫:
表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>




相關文章

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。