两个下拉框,取同一组数据,第二个框中不显示第一框中已选值
<select>
<%
Set conn=Server.CreateObject("ADODB.Connection")
DBPath1=server.mappath("../db/db.mdb")
conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath1
set rs=conn.execute("select a from b")
do while not rs.eof
%>
<option><%=rs("a")%></option>
<%
rs.movenext
loop
%>
</select>
<select>
<%
rs.movefirst
do while not rs.eof
%>
<option><%=rs("a")%></option>
<%
rs.movenext
loop
%>
</select>
<%
Dim list
Set conn=Server.CreateObject("ADODB.Connection")
DBPath1=server.mappath("../db/db.mdb")
conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath1
set rs=conn.execute("select a from b")
do while not rs.eof
list=list&",'"&rs("a")&"'"
rs.movenext
Loop
Rs.Close:Set Rs=Nothing
%>
<script type="text/javascript">参考文章:http://www.scscms.com/html/article/2012-1171321522.html
var txt=[<%=list%>];//下拉菜单文本
var num=6;//生成几级下拉菜单(从0算起,但不可超出数组下标)
var i_all=num>txt.length-1?txt.length-1:num;//判断是否超出数组下标
var str="";
for(var i=0;i<=i_all;i++){
if(i<i_all){
str+='<select name="sel'+i+'" onchange="option('+i+')" id="sel'+i+'">';
}else{
str+='<select name="sel'+i+'" id="sel'+i+'">';
}
if(i==0){
for(var n=0;n<txt.length;n++){
str+='<option>'+txt[n]+'</option>';
}
}
str+='</select>';
}
document.getElementById("list").innerHTML=str;
function option(i){
if(i>=i_all)return;
var obj=document.getElementById("sel"+i);
var opt=obj.options;
var thi=document.getElementById("sel"+(i+1));
thi.innerHTML="";
for(var n=0;n<opt.length;n++){
if(n!=obj.selectedIndex){
str = new Option(opt[n].text,"");
thi.options.add(str);
}
}
if(i+1<i_all)option(i+1);
}
option(0);
</script>