简单点你自己改进一下<SELECT NAME="sel1" onchange="update(this,'sel2');"></SELECT>
<SELECT NAME="sel2" onchange="update(this,'sel3');"></SELECT>
<SELECT NAME="sel3"></SELECT>
<SCRIPT LANGUAGE="JavaScript">
<!--
function myItem(val,txt){
this.value = val;
this.text = txt;
this.lvl = val.length/2;
this.pVal = (val.length>2) ? val.substring(0,val.length-2) : null;
}
var list = new Array();
list[list.length]= new myItem('01','成品');
list[list.length]= new myItem('0101','SpeechEasy');
list[list.length]= new myItem('0102','SpeechEasy basic');
list[list.length]= new myItem('0103','SpeechEasy Advanced');
list[list.length]= new myItem('010101','CIC');
list[list.length]= new myItem('010102','Mini-ITC');
list[list.length]= new myItem('010103','ITC');
list[list.length]= new myItem('02','原料/配件');
list[list.length]= new myItem('0201','芯片');
list[list.length]= new myItem('0202','扬声器');
list[list.length]= new myItem('03','工仪器具');
list[list.length]= new myItem('0301','编程器');
list[list.length]= new myItem('0302','助听器测试仪');
//....function update(obj,des){
var sel = document.all(des);
sel.options.length=0;
var curVal = obj.value;
for (var i=0; i < list.length; i++){
if (list[i].pVal == curVal){
sel.options[sel.options.length] = new Option(list[i].text,list[i].value);
}
}
}
function initSel(){
var sel = document.all('sel1');
for (var i=0; i < list.length; i++){
if (list[i].lvl == 1){
sel.options[sel.options.length] = new Option(list[i].text,list[i].value);
}
}
}
initSel();//-->
</SCRIPT>
<SELECT NAME="sel2" onchange="update(this,'sel3');"></SELECT>
<SELECT NAME="sel3"></SELECT>
<SCRIPT LANGUAGE="JavaScript">
<!--
function myItem(val,txt){
this.value = val;
this.text = txt;
this.lvl = val.length/2;
this.pVal = (val.length>2) ? val.substring(0,val.length-2) : null;
}
var list = new Array();
list[list.length]= new myItem('01','成品');
list[list.length]= new myItem('0101','SpeechEasy');
list[list.length]= new myItem('0102','SpeechEasy basic');
list[list.length]= new myItem('0103','SpeechEasy Advanced');
list[list.length]= new myItem('010101','CIC');
list[list.length]= new myItem('010102','Mini-ITC');
list[list.length]= new myItem('010103','ITC');
list[list.length]= new myItem('02','原料/配件');
list[list.length]= new myItem('0201','芯片');
list[list.length]= new myItem('0202','扬声器');
list[list.length]= new myItem('03','工仪器具');
list[list.length]= new myItem('0301','编程器');
list[list.length]= new myItem('0302','助听器测试仪');
//....function update(obj,des){
var sel = document.all(des);
sel.options.length=0;
var curVal = obj.value;
for (var i=0; i < list.length; i++){
if (list[i].pVal == curVal){
sel.options[sel.options.length] = new Option(list[i].text,list[i].value);
}
}
}
function initSel(){
var sel = document.all('sel1');
for (var i=0; i < list.length; i++){
if (list[i].lvl == 1){
sel.options[sel.options.length] = new Option(list[i].text,list[i].value);
}
}
}
initSel();//-->
</SCRIPT>
解决了大部分问题。
照gzh_seagull你说的,生成的数组是静态的,如果表是数据库里面的表,数组根据查出来的情况生成应该怎样做呢???
do while not rs.eof
%>
list[list.length]= new myItem('<%rs("KindID ")%>','<%=rs("Content ")%>');
<%
rs.movenext
loop
%>
我在点击了查找以后list里面应该是选择的内容啊,但是却是缺省的全部!!!
function initSel(){
var sel = document.all('sel1');
var sel2 = document.all('sel2');
var sel3 = document.all('sel3');
sel.options[sel.options.length] = new Option('全部','');
sel2.options[sel2.options.length] = new Option('全部','');
sel3.options[sel3.options.length] = new Option('全部','');
for (var i=0; i < list.length; i++){
if (list[i].lvl == 1){
sel.options[sel.options.length] = new Option(list[i].text,list[i].value);
}
}
}
这个是你给我的初始化程序,你改一改看??
var sel = document.all('sel1');
var sel2 = document.all('sel2');
var sel3 = document.all('sel3');
sel.options[sel.options.length] = new Option('全部','');
sel2.options[sel2.options.length] = new Option('全部','');
sel3.options[sel3.options.length] = new Option('全部','');
for (var i=0; i < list.length; i++){
if (list[i].lvl == 1){
sel.options[sel.options.length] = new Option(list[i].text,list[i].value);
}
}
<%
sel1 = request.form("sel1")
sel2 = request.form("sel2")
sel3 = request.form("sel3")
%>
sel.value="<%=sel1%>";
update(sel,'sel2');
sel2.value="<%=sel2%>"
update(sel2,'sel3');
sel3.value="<%=sel3%>"
}