两种js动态三级联动下拉表单测试
2007-06-14 09:48
477 查看
<html>
<head>
<title>三级联动下拉表单测试一</title>
<!--=======连接IT网主数据库======-->
</head>
<body>
<form name="myform" method="post">
<%
set rs=server.CreateObject("adodb.recordset")
sq="select * from 一级表"
rs.open sq,conn,1,1
%>
<select name="class1" onChange="changeclass2();changeclass3()">
<option value="" selected>选择一级目录</option>
<%
while not rs.eof
%>
<option value="<%=rs("一级类")%>"><%=rs("一级类")
%>
</option>
<%
rs.movenext
wend
rs.close
%>
</select>
<select name="class2" onChange="changeclass3()">
<option value="" selected>选择二级目录</option>
</select>
<select name="class3">
<option value="" selected>选择三级目录</option>
</select>
<%
sql="select * from 二级表"
rs.open sql,conn,1,1
num=rs.recordcount
str=""
for i=1 to rs.recordcount
str=str&rs("一级类")&"-"&rs("二级类")&","
if rs.eof then exit for
rs.movenext
next
rs.close
%>
<%
sql="select * from 三级表"
rs.open sql,conn,1,1
num2=rs.recordcount
str2=""
for i=1 to rs.recordcount
str2=str2&rs("二级类")&"-"&rs("三级类")&","
if rs.eof then exit for
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;
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]));
}
}
}
</script>
</body>
</html>
Reqeust获取参数实现动态三级联动下拉表单
<!--#include file="conn.asp"-->
<%
dim cid,coid
cid = request("cid") 'cid 大类id
coid = request("coid") 'coid 中类id
set rs=server.createobject("adodb.recordset")
sql = "select * from PE_Area" '表一 大类表
rs.open sql,conn,1,1
strOption1 = "<option value='' selected >==请选择所属市==</option>"
do while not rs.eof
if cstr(rs("id")) = cstr(cid) then
strOption1 = strOption1 & "<option value='" & rs("id") & "' selected>" & rs("c_name") & "</option>"
else
strOption1 = strOption1 & "<option value='" & rs("id") & "'>" & rs("c_name") & "</option>"
end if
rs.movenext
loop
rs.close
if cid <> "" then
sql = "select * from PE_Area where c_id=" & cid '表二 中类表 bid==表一中的id
rs.open sql,conn,1,1
strOption2 = "<option value='' selected >==请选择所属县==</option>"
do while not rs.eof
if cstr(rs("id")) = cstr(coid) then
strOption2 = strOption2 & "<option value='" & rs("id") & "' selected>" & rs("co_name") & "</option>"
else
strOption2 = strOption2 & "<option value='" & rs("id") & "'>" & rs("co_name") & "</option>"
end if
rs.movenext
loop
rs.close
end if
if coid <> "" then
sql = "select * from PE_Area where co_id= " & coid '表三 小类表 mid==表二的id
rs.open sql,conn,1,1
strOption3 = "<option value='' selected >==请选择乡==</option>"
while not rs.eof
if cstr(rs("id")) = cstr(sid) then
strOption3 = strOption3 & "<option value='" & rs("id") & "' selected>" & rs("s_name") & "</option>"
else
strOption3 = strOption3 & "<option value='" & rs("id") & "'>" & rs("s_name") & "</option>"
end if
rs.movenext
wend
rs.close
end if
%>
<select onchange="changeb(this.value)" name="cid"><%=strOption1%></select>
<select onchange="change(this.value)" name="coid"><%=strOption2%></select>
<select name="sid"><%=strOption3%></select>
<script language="javascript">
<!--
function changeb(cid){
location.assign("three.asp?action=s_s&cid=" + cid);
}
function change(coid){
location.assign("three.asp?action=s_s&cid=<%=cid%>&coid=" + coid);
}
-->
</script>
上面给出的是三级联动菜单,四级,多级联动菜单的制作一一类推。
<head>
<title>三级联动下拉表单测试一</title>
<!--=======连接IT网主数据库======-->
</head>
<body>
<form name="myform" method="post">
<%
set rs=server.CreateObject("adodb.recordset")
sq="select * from 一级表"
rs.open sq,conn,1,1
%>
<select name="class1" onChange="changeclass2();changeclass3()">
<option value="" selected>选择一级目录</option>
<%
while not rs.eof
%>
<option value="<%=rs("一级类")%>"><%=rs("一级类")
%>
</option>
<%
rs.movenext
wend
rs.close
%>
</select>
<select name="class2" onChange="changeclass3()">
<option value="" selected>选择二级目录</option>
</select>
<select name="class3">
<option value="" selected>选择三级目录</option>
</select>
<%
sql="select * from 二级表"
rs.open sql,conn,1,1
num=rs.recordcount
str=""
for i=1 to rs.recordcount
str=str&rs("一级类")&"-"&rs("二级类")&","
if rs.eof then exit for
rs.movenext
next
rs.close
%>
<%
sql="select * from 三级表"
rs.open sql,conn,1,1
num2=rs.recordcount
str2=""
for i=1 to rs.recordcount
str2=str2&rs("二级类")&"-"&rs("三级类")&","
if rs.eof then exit for
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;
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]));
}
}
}
</script>
</body>
</html>
Reqeust获取参数实现动态三级联动下拉表单
<!--#include file="conn.asp"-->
<%
dim cid,coid
cid = request("cid") 'cid 大类id
coid = request("coid") 'coid 中类id
set rs=server.createobject("adodb.recordset")
sql = "select * from PE_Area" '表一 大类表
rs.open sql,conn,1,1
strOption1 = "<option value='' selected >==请选择所属市==</option>"
do while not rs.eof
if cstr(rs("id")) = cstr(cid) then
strOption1 = strOption1 & "<option value='" & rs("id") & "' selected>" & rs("c_name") & "</option>"
else
strOption1 = strOption1 & "<option value='" & rs("id") & "'>" & rs("c_name") & "</option>"
end if
rs.movenext
loop
rs.close
if cid <> "" then
sql = "select * from PE_Area where c_id=" & cid '表二 中类表 bid==表一中的id
rs.open sql,conn,1,1
strOption2 = "<option value='' selected >==请选择所属县==</option>"
do while not rs.eof
if cstr(rs("id")) = cstr(coid) then
strOption2 = strOption2 & "<option value='" & rs("id") & "' selected>" & rs("co_name") & "</option>"
else
strOption2 = strOption2 & "<option value='" & rs("id") & "'>" & rs("co_name") & "</option>"
end if
rs.movenext
loop
rs.close
end if
if coid <> "" then
sql = "select * from PE_Area where co_id= " & coid '表三 小类表 mid==表二的id
rs.open sql,conn,1,1
strOption3 = "<option value='' selected >==请选择乡==</option>"
while not rs.eof
if cstr(rs("id")) = cstr(sid) then
strOption3 = strOption3 & "<option value='" & rs("id") & "' selected>" & rs("s_name") & "</option>"
else
strOption3 = strOption3 & "<option value='" & rs("id") & "'>" & rs("s_name") & "</option>"
end if
rs.movenext
wend
rs.close
end if
%>
<select onchange="changeb(this.value)" name="cid"><%=strOption1%></select>
<select onchange="change(this.value)" name="coid"><%=strOption2%></select>
<select name="sid"><%=strOption3%></select>
<script language="javascript">
<!--
function changeb(cid){
location.assign("three.asp?action=s_s&cid=" + cid);
}
function change(coid){
location.assign("three.asp?action=s_s&cid=<%=cid%>&coid=" + coid);
}
-->
</script>
上面给出的是三级联动菜单,四级,多级联动菜单的制作一一类推。
相关文章推荐
- 三级联动下拉表单的源代码
- jQuey/js 省市县三级下拉框联动的回显(简单易懂)
- 【Angular】二级联动:如何从js二级联动,下拉框内容为动态查询
- jquery.cxselect.js的使用案例 (动态数据的三级联动)
- js入门·表单元素(select下拉列表)制作二级联动菜单和网站导航 .txt
- js入门·表单元素(select下拉列表)制作二级联动菜单和网站导航
- layer表单元素 三级联动 省市县选择框动态渲染问题解决
- js操纵跨frame的三级联动select下拉选项
- jsp中,使用js生成动态的数据库相关的二级联动下拉框
- js实现年月日表单三级联动
- ASP+JS动态实现(数据库)三级联动下拉菜单
- js操纵跨frame的三级联动select下拉选项实例介绍
- JS对select动态添加option操作 (三级联动) (搜索拼接)
- 简单的js日期三级联动下拉代码
- 原生JavaScript实现动态省市县三级联动下拉框菜单实例代码
- JS和Ajax 实现三级联动的下拉选择
- 用JS动态改变表单form里的action值属性的两种方法
- AJAX部分---对比js做日期的下拉选择 和 ajax做三级联动;
- 【JS插件】下拉框通用三级联动选择 省市区三级联动选择