三级联动问题
想做一个三级联动的菜单,但是只实现了一个,第二个没有起作用,找不到原因,在此麻烦各位大神帮看看,错在哪里。谢谢了!提示错误是:‘document.addNEWS.SsclassName‘为空或不是对象。程序代码:
<% dim rs dim rs2 dim rs3 dim sql dim sql2 dim sql3 dim count dim count2 set rs=server.createobject("adodb.recordset") sql = "select * from SmallClass where SmallClassID order by SmallClassID asc" rs.open sql,conn,1,1 set rs2=server.createobject("adodb.recordset") sql2="select * from ssclass order by ssid asc" rs2.open sql2,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("BigClassName"))%>","<%= trim(rs("SmallClassName"))%>"); <% count = count + 1 rs.movenext loop rs.close %> onecount=<%=count%>; function changelocation(locationid) { document.addNEWS.SmallClassName.length = 1; var locationid=locationid; var i; for (i=0;i < onecount; i++) { if (subcat[i][1] == locationid) { document.addNEWS.SmallClassName.options[document.addNEWS.SmallClassName.length] = new Option(subcat[i][0], subcat[i][2]); } } } var onecount2; subcat2=new Array(); <% count2=0 do while not rs2.eof %> subcat2[<%=count2%>]=new Array("<%= trim(rs2("SscalssName"))%>","<%= trim(rs2("SmallClassName"))%>","<%= trim(rs2("SscalssName"))%>"); <% count2 = count2 + 1 rs2.movenext loop rs2.close %> onecount2=<%=count2%>; function changelocation2(locationid2) { document.addNEWS.SsClassName.length=1; var locationid2=locationid2; var j; for(j=0;j<onecount;j++) { if(subcat[j][1]==locationid2) { document.addNEWS.SsclassName.options[document.addNEWS.SsclassName.length] = new Option(subcat2[j][0], subcat2[j][2]); } } } </script> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <link rel="stylesheet" href="../include/css.css" type="text/css"> <title>添加文章</title> </head> <body leftmargin="0" topmargin="0" bgcolor="#FFFFEE"> <table width="90%" border="0" align="center" cellpadding="0" cellspacing="2"> <form name="addNEWS" method="post" action="addinfo_ok.asp" onSubmit="return CheckForm();"> <tr> <td height="25"><font color="#FF0000">*</font>新闻类别:</td> <td colspan="2"> <% sql = "select * from BigClass where urlok=0 and bigclassid in ("&session("strbigidtype")&")" rs.open sql,conn,1,1 if rs.eof and rs.bof then response.write "请先添加栏目。" else %> <select name="BigClassName" onChange="changelocation(document.addNEWS.BigClassName.options[document.addNEWS.BigClassName.selectedIndex].value)" size="1"> <option selected value="<%=trim(rs("BigClassName"))%>"><%=trim(rs("BigClassName"))%></option> <% dim selclass selclass=rs("BigClassName") rs.movenext do while not rs.eof %> <option value="<%=trim(rs("BigClassName"))%>"><%=trim(rs("BigClassName"))%></option> <% rs.movenext loop end if rs.close %> </select> <% sql2 = "select * from SmallClass where BigClassName='" & selclass & "'" rs2.open sql2,conn,1,1 if rs2.eof and rs2.bof then response.write "请先添加二级栏目。" else %> <select name="SmallClassName" onChange="changelocation2(document.addNEWS.SmallClassName.options[document.addNEWS.SmallClassName.selectedIndex].value)"> <option value="" selected>***请指定二级分类***</option><option selected value="<%=trim(rs2("SmallClassName"))%>"><%=trim(rs2("SmallClassName"))%></option> <% dim selclass2 selclass2=rs2("SmallClassName") rs2.movenext do while not rs2.eof %> <option value="<%=trim(rs2("SmallClassName"))%>"><%=trim(rs2("SmallClassName"))%></option> <% rs2.movenext loop end if rs2.close %> </select> <%response.Write(selclass2)%> <% Set rs3 = Server.CreateObject("ADODB.Recordset") sql3 = "select * from ssclass where SmallClassName='" & selclass2 & "'" rs3.open sql3,conn,1,1 if rs3.eof and rs3.bof then response.write "请先添加三级栏目。" else %> <select name="SscalssName"><option value="" selected>请指定三级分类</option> <option selected value="<%=trim(rs3("SscalssName"))%>"><%=trim(rs3("SscalssName"))%></option> <% dim selclass3 selclass3=rs3("SmallClassName") rs3.movenext do while not rs3.eof %> <option value="<%=trim(rs3("SscalssName"))%>"><%=trim(rs3("SscalssName"))%></option> <% rs3.movenext loop end if rs3.close %> </select> </td> </tr> </table> </body> </html>