求一三级联动JS代码

<!--#include file="check.asp"-->
<%dim count
set ps=server.createobject("adodb.recordset")
ps.open "select * from smallclass",conn,1,1%>
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
<%
count = 0
do while not ps.eof
%>
subcat[<%=count%>] = new Array("<%= trim(ps("smallclass"))%>","<%= ps("bigclassid")%>","<%= ps("smallclassid")%>");
<%
count = count + 1
ps.movenext
loop
ps.close
%>

onecount=<%=count%>;

function changelocation(locationid)
{
document.myform.smallclassid.length = 0;

var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.myform.smallclassid.options[document.myform.smallclassid.length] = new Option(subcat[i][0], subcat[i][2]);
}
}

}
</script>
<%
ps.open "select * from bigclass",conn,1,1
if ps.eof and ps.bof then%>
<font color="#FF0000">请先添加栏目</font>
<%response.end
else
%>
一级信息:
<select name="bigclassid" size="1" id="bigclassid" onChange="changelocation(document.myform.bigclassid.options[document.myform.bigclassid.selectedIndex].value)">
<option selected value="<%=ps("bigclassid")%>"><%=trim(ps("bigclass"))%></option>
<% dim selclass
selclass=ps("bigclassid")
ps.movenext
do while not ps.eof
%>
<option value="<%=ps("bigclassid")%>"><%=trim(ps("bigclass"))%></option>
<%
ps.movenext
loop
end if
ps.close
%>
</select>
二级信息:
<select name="smallclassid">
<%ps.open "select * from smallclass where bigclassid="&selclass ,conn,1,1
if not(ps.eof and ps.bof) then
%>
<option selected value="<%=ps("smallclassID")%>"><%=ps("smallclass")%></option>
<% ps.movenext
do while not ps.eof%>
<option value="<%=ps("smallclassID")%>"><%=ps("smallclass")%></option>
<% ps.movenext
loop
end if
ps.close
set ps = nothing
%>
</select>
如何将这个二级改成三级联动?

<form method="post" name="myform">
<select name="classid" onchange="select()"></select>
<select name="suid"></select>
<select name="gid"></select>
</form>
<script language="javascript">
<!--
var arrText = new Array(5);
var arrValue = new Array(arrText.length);

function objSetOption(select1, select2, select3) {
this.select1 = select1;
this.select2 = select2;
this.select3 = select3;
}

arrText[0]= new objSetOption("选择1:", "选择2_1:,选择2_2:", "选择3_1:,选择3_2:");
arrText[1] = new objSetOption("论文:1", "语文:1,数学:2,英语:3", "初中:2,高中:3");
arrText[2] = new objSetOption("例题:2", "显示b2_1:值b2_1,显示b2_2:值b2_2", "显示b3_1:值b3_1,显示b3_2:值b3_2");
arrText[3] = new objSetOption("显示c:值c", "显示c2_1:值c2_1,显示c2_2:值c2_2", "显示c3_1:值c3_1,显示c3_2:值c3_2");
arrText[4] = new objSetOption("显示d:值d", "显示d2_1:值d2_1,显示d2_2:值d2_2", "显示d3_1:值d3_1,显示d3_2:值d3_2");
arrText[5] = new objSetOption("显示e:值e", "显示e2_1:值e2_1,显示e2_2:值e2_2", "显示e3_1:值e3_1,显示e3_2:值e3_2");

function select(sValue1, sValue2, sValue3) {
var eltSelect1 = document.myform.classid;
var eltSelect2 = document.myform.suid;
var eltSelect3 = document.myform.gid;
var arrSelect1, arrSelect2, arrSelect3;
var arrData1, arrData2, arrData3;
with(eltSelect1) {
var strSelect = options[selectedIndex].value;
}
for(i = 0;i < arrText.length;i ++) {
arrSelect1 = arrText[i].select1;
arrData1 = arrSelect1.split(":");
if (arrData1[1] == strSelect) {
arrSelect2 = (arrText[i].select2).split(",");
for(j = 0;j < arrSelect2.length;j++) {
arrData2 = arrSelect2[j].split(":");
with(eltSelect2) {
length = arrSelect2.length;
options[j].text = arrData2[0];
options[j].value = arrData2[1];
if (arrData2[1] == sValue2) {
options[j].selected = true;
}
}
}
arrSelect3 = (arrText[i].select3).split(",");
for(j = 0;j < arrSelect3.length;j++) {
arrData3 = arrSelect3[j].split(":");
with(eltSelect3) {
length = arrSelect3.length;
options[j].text = arrData3[0];
options[j].value = arrData3[1];
if (arrData3[1] == sValue3) {
options[j].selected = true;
}
}
}
break;
}
}
}

function init(sValue1, sValue2, sValue3) {
var eltSelect1 = document.myform.classid;
var eltSelect2 = document.myform.suid;
var eltSelect3 = document.myform.gid;
var arrSelect1, arrSelect2, arrSelect3;
var arrData1, arrData2, arrData3;
if (eltSelect1 != undefined && eltSelect2 != undefined && eltSelect3 != undefined) {
with(eltSelect2) {
arrSelect2 = (arrText[0].select2).split(",");
length = arrSelect2.length;
for(i = 0;i < length;i ++) {
arrData2 = arrSelect2[i].split(":");
options[i].text = arrData2[0];
options[i].value = arrData2[1];
}
}
with(eltSelect3) {
arrSelect3 = (arrText[0].select3).split(",");
length = arrSelect3.length;
for(i = 0;i < length;i ++) {
arrData3 = arrSelect3[i].split(":");
options[i].text = arrData3[0];
options[i].value = arrData3[1];
}
}
with(eltSelect1) {
length = arrText.length;
for(i = 0;i < arrText.length;i ++) {
arrSelect1 = arrText[i].select1;
arrData1 = arrSelect1.split(":");
options[i].text = arrData1[0];
options[i].value = arrData1[1];
if (arrData1[1] == sValue1) {
options[i].selected = true;
select("", sValue2, sValue3);
}
}
}
}
}

//init();
//默认初始化

init("2", "值b2_1", "值b3_2");
//更改后默认初始化
// -->
</script>
温馨提示:内容为网友见解,仅供参考
无其他回答

详解JS实现三级联动菜单(附思路说明)
在解析JS实现三级联动菜单的过程中,首先明确每个下拉菜单作为一个组件,接收一组数据,根据内容生成菜单选项。三级菜单间的关联通过事件抛发完成。数据从后台获取。当用户选择省份如陕西,组件通过事件抛发当前省份信息。借此获取省份对应城市数据。以此类推。实现三级级联菜单涉及前后端交互,具体接口信息如下:...

如何直接在jsp中实现三级联动,就直接写死在jsp中 不在数据库中提取数据...
一:JS文件:复制代码 function Dsy(){ this.Items = {};} Dsy.prototype.add = function(id,iArray){ this.Items[id] = iArray;} Dsy.prototype.Exists = function(id){ if(typeof(this.Items[id]) == "undefined") return false;return true;} function change(v){ var str="0";fo...

js高手帮忙省市县三级联动
dsy.add("0_8_1",["泊头市","沧县","沧州市","东光县","海兴县","河间市","黄骅市","孟村回族自治县","南皮县","青县","任丘市","肃宁县","吴桥县","献县","盐山县"]);dsy.add("0_8_2",["承德市","承德县","丰宁满族自治县","宽城满族自治县","隆化县","滦平县","平泉县","...

关于三级连动
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 > <!--下面是实现动态改变下一级菜单的脚本代码--> arr="<%=st...

js三级联动数组的代码第三级获取不到怎么回事?
js使用中括号获取数组中的值,例如获取数组a的第一个元素,那么就写: a[0]

省市区三级联动下拉菜单应该怎么写
JS 省市区三级联动: <!DOCTYPE html PUBLIC "-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN" "http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd">JS 省市区三级联动 var temp;var P = new Array();var C = new Array()...

asp.net(C#)如何做省市县三级联动
Manager,再拖一个update panel.把需要联动的东西放到panel里面来。然后把联动事件和初始化联动菜单的代码一写,把联动菜单控件(我用的是LIstbox,当然可以用DDL)的postback属性设置为true。呵呵,居然成了,三级无刷。而且页面上一个JS都没有哟!代码简单,我就喜欢这样。只是分享一下我的经验,呵呵。

我用的是JS实现的省市县三级联动,但是存入数据库里的是他们的所属编号...
河北省 弄成这样 只要获取 就获取的是 编号

就是用javascript写三级联动的时候,老是报错,这个到底哪里错了_百度...
还有几处错误,完整代码如下(注意修改jquery引用):<!DOCTYPE HTML> Test ---请选择--- ---请选择--- ---请选择---

《求高手》三级联动直接进入文本字段
北京1 北京2 海淀 海淀1 海淀2 中关村 中关村1 中关村2

相似回答