二级联动

来源:互联网 发布:ff14捏脸数据 雷霆 编辑:程序博客网 时间:2024/04/27 20:34

<!--#include file="include/conn.asp"-->
<html>
<head>
<title>List</title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<script LANGUAGE="javascript">
<!--

var onecount;
onecount=0;
var subcat = new Array();
<% 
 dim rCity,iCount
 iCount=0
 set rCity=Server.CreateObject("ADODB.Recordset")
 rCity.Open "SELECT * FROM Region where ParID<>0",conn,1,1
 while not rCity.EOF 
  response.write "subcat[" & iCount & "]=new Array(""" & rCity("Name")   &  """,""" & rCity("ParID") &  """,""" & rCity("ID") &  """);" & vbcr
  iCount=iCount+1
  rCity.MoveNext
 wend
 rCity.Close
 set rCity=nothing
 
 response.write "onecount=" & iCount & ";"
 
%>

function changelocation(locationid)
{
 
 document.myform.smalllocation.length = 0;
 var i;
 document.myform.smalllocation.options[0] = new Option('选择地区','0');
 
 for (i=0;i < onecount; i++)
 {
  if (subcat[i][1]== locationid)
  {
   document.myform.smalllocation.options[document.myform.smalllocation.length] = new Option(subcat[i][0], subcat[i][2]);
  }
 }

}

//-->
</script>
</head>
<body>
<form name="myform" method="post">


<select name="biglocation" onChange="changelocation(document.myform.biglocation.options[document.myform.biglocation.selectedIndex].value)">
<option selected value="0">请选择省</option>

<%
 dim rProvince
 set rProvince=server.CreateObject("ADODB.Recordset")
 rProvince.Open "select * from Region where ParID=0",conn,1,1
 while not rProvince.EOF
  %>
  <option value="<%=rProvince("ID")%>"><%=rProvince("Name")%></option>
  <%
  rProvince.MoveNext 
 wend
 rProvince.Close
 set rProvince=nothing
 
%>

 

</select>
<select name="smalllocation">
<option selected value="0">请选择市</option>
</select>
</form>
</body>
</html>

原创粉丝点击