标题:一个四级联动的问题
只看楼主
shuiyuan0929
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2006-3-13
 问题点数:0 回复次数:1 
一个四级联动的问题
我想写一个企业的所在地, 有国家,省份 ,地级市, 市、县级市、县的,怎么才能让他选择的时候得到相应的地区,是不是的用js啊?如果是能不能给我这个问题的js文件啊?
搜索更多相关主题的帖子: 四级 
2006-04-24 09:05
xieyanyong00
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2006-3-24
得分:0 

<html>
<head>
<title>四级连跳</title>
<%
Set Conn = Server.CreateObject("ADODB.Connection")
StrCnn = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("date.mdb") & ";"
Conn.Open StrCnn
%>
</head>
<body>
<form name="myform" method="post">
<% set rs=server.CreateObject("adodb.recordset")
sq="select * from class1"
rs.open sq,conn,1,1
%>
<select name="class1" onChange="changeclass2();changeclass3();changeclass4()">
<option value="" selected>选择一级目录</option>
<%
while not rs.eof
%>
<option value="<%=rs("class1")%>"><%=rs("class1")%></option>
<%rs.movenext
wend
rs.close%>
</select>
<select name="class2" onChange="changeclass3();changeclass4()">
<option value="" selected>选择二级目录</option>
</select>
<select name="class3" onChange="changeclass4()">
<option value="" selected>选择三级目录</option> </select>
<select name="class4">
<option value="" selected>选择四级目录</option> </select>
<%sql="select * from class2"
rs.open sql,conn,1,1
num=rs.recordcount
str=""
for i=1 to rs.recordcount
str=str&rs("class1")&"-"&rs("class2")&","
if rs.eof then
exit for
end if
rs.movenext
next
rs.close
%>
<%
sql="select * from class3"
rs.open sql,conn,1,1
num2=rs.recordcount
str2=""
for i=1 to rs.recordcount
str2=str2&rs("class2")&"-"&rs("class3")&","
if rs.eof then
exit for
end if
rs.movenext
next
rs.close %>


<%
sql="select * from class4"
rs.open sql,conn,1,1
num3=rs.recordcount
str3=""
for i=1 to rs.recordcount
str3=str3&rs("class3")&"-"&rs("class4")&","
if rs.eof then
exit for
end if
rs.movenext
next
rs.close %>

<script LANGUAGE="javascript">
arr="<%=str%>".split(",");
a=arr.length
ar=new Array()
for (i=0;i<a;i++)
{ ar[i]=arr[i].split("-");
}
onecount=ar.length;
arr2="<%=str2%>".split(",");
a2=arr2.length
ar2=new Array()
for (i=0;i<a2;i++)
{
ar2[i]=arr2[i].split("-");
}
onecount2=ar2.length;




arr3="<%=str3%>".split(",");
a3=arr3.length
ar3=new Array()
for (i=0;i<a3;i++)
{
ar3[i]=arr3[i].split("-");
}
onecount3=ar3.length;







function changeclass2()
{ document.myform.class2.length=0
lid=myform.class1.value;
for (i=0;i<onecount;i++)
{
if (ar[i][0] == lid) {
document.myform.class2.options.add(new Option(ar[i][1], ar[i][1]));
}
}
}
function changeclass3()
{
document.myform.class3.length=0
lid2=myform.class2.value;
for (i=0;i<onecount2;i++)
{ if (ar2[i][0] == lid2)
{ document.myform.class3.options.add(new Option(ar2[i][1], ar2

[i][1])); }
}

}


function changeclass4()
{
document.myform.class4.length=0
lid3=myform.class3.value;
for (i=0;i<onecount3;i++)
{ if (ar3[i][0] == lid3)
{ document.myform.class4.options.add(new Option(ar3[i][1], ar3[i][1])); }
}
}
</script>
</body>
</html>

2006-10-07 16:13



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-59622-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.368258 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved