我现在想要个三级的,就是选定大类小类自动出现所有属于这个大类的小类,然后在这里面选定小类以后,三级类别,所有属于这个小类的所以三级类被自动选定,类似小类的功能..
我现在把二级类的代码和函数公布一下,大家帮忙改一下..
var onecount; onecount=0; subcat = new Array(); <% count = 0 do while not rs.eof %> subcat[<%=count%>] = new Array("<%= trim(rs("sorts"))%>","<%= rs("categoryid")%>","<%= rs("sortsid")%>"); <% count = count + 1 rs.movenext loop rs.close %> onecount=<%=count%>;
function changelocation(locationid) { document.myform.sortsid.length = 0;
var locationid=locationid; var i; for (i=0;i < onecount; i++) { if (subcat[i][1] == locationid) { document.myform.sortsid.options[document.myform.sortsid.length] = new Option(subcat[i][0], subcat[i][2]); } } } <% rs.open "select * from category order by categoryorder",conn,1,1 if rs.eof and rs.bof then response.write "没有东西!" response.end else %> <select name="categoryid" size="1" id="categoryid" onChange="changelocation(document.myform.categoryid.options[document.myform.categoryid.selectedIndex].value)"> <option selected value="<%=rs("categoryid")%>"><%=trim(rs("category"))%></option> <% dim selclass selclass=rs("categoryid") rs.movenext do while not rs.eof %> <option value="<%=rs("categoryid")%>"><%=trim(rs("category"))%></option> <% rs.movenext loop end if rs.close %> </select> 所属小类 <select name="sortsid"> <% rs.open "select * from sorts where categoryid="&selclass ,conn,1,1 if not(rs.eof and rs.bof) then %> <option selected value="<%=rs("sortsid")%>"><%=rs("sorts")%></option> <% rs.movenext do while not rs.eof %> <option value="<%=rs("sortsid")%>"><%=rs("sorts")%></option> <% rs.movenext loop end if rs.close rs.open "select * from TimesProList",conn,1,1 %> </select> 大家帮忙改一下..

<%
set rs=server.createobject("adodb.recordset")
rs.open"select * from class_two",conn,1,1
%>
‘---------以上是查询出第一级下拉列表的内容-----
’---------以下是用JS来控制程序--------------
<script language = "JavaScript">
var onecount; //定义onecount对像
onecount=0;//初始值为0
subcat = new Array(); //SUBCAT对像是一个新的数组
<%
count = 0 '定义count对像初始值为0
do while not rs.eof '循环表头到表尾
%>
subcat[<%=count%>] = new Array("<%=rs("class_two_text")%>","<%=trim(rs("class_one"))%>","<%=trim(rs("class_two"))%>");
//以上为重点内容,对像数组(subcat[count对像值])= 新数组内容('字段名0','字段名1','字段名2')记住要对应
<%
count = count + 1 '循环count一次,COUNT的值加1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;
function changelocation(locationid)
{
document.form.class_two.length = 0;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[1] == locationid)
{
document.form.class_two.options[document.form.class_two.length] = new Option(subcat[0], subcat[2]);
}
}
}
</script>
<%
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from Class_one" ,conn,1,1
if rs.eof then
response.Write"暂无产品一类名称"
else%>
产品一类
<select name="class_one" id="class_one"
onChange="changelocation(document.form.class_one.options[document.form.class_one.selectedIndex].value)">
<%do while not rs.eof%>
<option value="<%=rs("class_one")%>"><%=rs("class_one_text")%></option>
<%rs.movenext
loop
end if
%>
</select>
产品二类
<select name="class_two"
onChange="three(document.form.class_one.value,document.form.class_two.options[document.form.class_two.selectedIndex].value)">
<option value="请选择条件" selected>请选择条件</option>
</select> <%
set rs=server.createobject("adodb.recordset")
rs.open"select * from class_three",conn,1,1
%> <script language = "JavaScript">
var twocount;
twocount=0;
subthree = new Array();
<%
countb = 0
do while not rs.eof
%>
subthree[<%=countb%>] = new
Array("<%=rs("class_three_text")%>","<%=trim(rs("class_one"))%>","<%=trim(rs("class_two"))%>","<%=trim(rs("class_three"))%>");
<%
countb = countb + 1
rs.movenext
loop
rs.close
%>
twocount=<%=countb%>;
function three(threeid,threeid2)
{
document.form.class_three.length = 0;
var threeid=threeid;
var threeid2=threeid2;
var i;
for (i=0;i < twocount; i++)
{
if ((subthree[1] == threeid) & (subthree[2] == threeid2))
{
document.form.class_three.options[document.form.class_three.length] = new Option(subthree[0], [转自:飞腾设计网 www.feitec.com]
subthree[3]);
}
}
}
</script>
产品三类
<select name="class_three" id="class_three">
<option value="0" selected>请选择条件</option>
</select> [转自:飞腾设计网 www.feitec.com]