关于三级联动下拉的问题弄了一天实用是还不行
以下是我的代码.
数据库三个表中分类已有.
英语
初级
1班
2班
23
3班
ds
23
ss
232311
23
2323
语文
s
2班
-----------------------
<!--#include file= "conn.asp "-->
<%
dim rs
dim sql
dim count
set rs=server.createobject( "adodb.recordset ")
sql = "select * from SmallClass order by SmallClassID asc "
rs.open sql,conn,1,1
%>
<script language = "JavaScript ">
var onecount;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[ <%=count%> ] = new Array( " <%= trim(rs( "SmallClassName "))%> ", " <%= trim(rs( "BigClassID "))%> ", " <%= trim(rs( "SmallClassID "))%> ");
<%
count = count + 1
rs.movenext
loop
rs.close
%>
onecount= <%=count%> ;
function changelocation(locationid)
{
document.myform.SmallClassID.length = 1;
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>
<%
dim rs2,sqla,count1
set rs2=server.createobject( "adodb.recordset ")
sqla = "select * from threeclass order by threeClassID asc "
rs2.open sql,conn,1,1
%>
<script language = "JavaScript ">
var onecount1;
subcat1 = new Array();
<%
count1 = 0
do while not rs2.eof
%>
subcat1[ <%=count1%> ] = new Array( " <%= trim(rs2( "threeClassName "))%> ", " <%= trim(rs2( "SmallClassID "))%> ", " <%= trim(rs2( "threeClassID "))%> ");
<%
count1 = count1 + 1
rs2.movenext
loop
rs2.close
%>
onecount1= <%=count1%> ;
function changelocation1(locationid1)
{
document.myform.threeClassID.length = 1;
var locationid1=locationid1;
var j;
for (j=0;i < onecount1; j++)
{
if (subcat1[i][1] == locationid1)
{
document.myform1.threeClassID.options[document.myform.threeClassID.length] = new Option(subcat1[j][0], subcat1[j][2]);
}
}
}
</script>
<table width= "100% " height= "100% " border= "0 " cellpadding= "0 " cellspacing= "0 ">
<tr>
<td width= "862 " align= "center " valign= "top "> <b> <br>
</b>
<form method= "POST " name= "myform " onSubmit= "return CheckForm(); " action= "ProductSave.asp?action=add " target= "_self ">
<table width= "650 " border= "0 " align= "center " cellpadding= "0 " cellspacing= "0 " class= "border ">
<tr align= "center ">
<td class= "tdbg "> <table width= "100% " border= "0 " cellpadding= "2 " cellspacing= "1 " class= "table_southidc ">
<tr>
<td class= "back_southidc " height= "22 " colspan= "2 " align= "right " bgcolor= "#A4B6D7 "> <div align= "center "> <b> 添
加 产 品 </b> </div> </td>
</tr>
<tr>
<td width= "150 " height= "22 " align= "right " bgcolor= "#A4B6D7 "> 所属类别: </td>
<td bgcolor= "#E3E3E3 "> <strong>
<%
sql = "select * from BigClass "
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "请先添加栏目。 "
else
%>
<select name= "BigClassID " size= "1 " id= "BigClassID " onChange= "changelocation(document.myform.BigClassID.options[document.myform.BigClassID.selectedIndex].value) ">
<option value= " " selected> 请选择课程 </option>
<%
do while not rs.eof
%>
<option value= " <%=trim(rs( "BigClassID "))%> "> <%=trim(rs( "BigClassName "))%> </option>
<%
rs.movenext
loop
end if
rs.close
%>
</select>
<select name= "SmallClassID " id= "SmallClassID " onChange= "changelocation1(document.myform.SmallClassID.options.value) ">
<option value= " " selected> 请选择分类 </option>
</select>
<select name= "threeClassID " id= "threeClassID ">
<option selected> 请选择班级 </option>
</select>
</strong> </td>
</tr>
</table> </td>
</tr>
</table>
</form> </td>
</tr>
</table>
[解决办法]
http://www.kudaa.com/Downlist.asp?ClassId=39
有个三级联动的代码。。带access 数据库。你下载后研究下就明白了。