<form name="myform">
<select name="sct1" onchange="changeSct2()">
<option value="xxx" selected>请选择大类……</option>
<%
set rs_Province=server.CreateObject("ADODB.recordset")
sql="select * from Category order by Categoryid"
rs_Province.open sql,conn,1,1
if rs_Province.recordcount>0 then
for i=1 to rs_province.recordcount
tmpid(i)=rs_province("Categoryid")
n=rs_province.recordcount
%>
<option value="<%=rs_Province("Categoryid")%>" ><%=trim(rs_Province("Category"))%></option>
<%
rs_Province.movenext
next
end if
rs_Province.close
set rs_Province=nothing
%>
</select>
</select>
<select name="sct2">
<option value="yyy" selected>请选择小类……</option>
</select>
</form>
<script>
function changeSct2() {
switch (document.myform.sct1.options[document.myform.sct1.selectedIndex].value) {
<%
for i=1 to n
%>
case "<%=i%>" : choose<%=i%>();break;
<%
next
%>
}
}
<%for j=1 to n%>
function choose<%=j%>() {
sct2obj=document.myform.sct2;
for(i=1;i<sct2obj.length+1;i++) {//用sct2obj.length=2亦可
sct2obj.options[i]=null;
}
<%set rs_City=server.CreateObject("ADODB.recordset")
sql="select * from Sorts where Categoryid="&tmpid(j)&" order by Sortsid"
rs_City.open sql,conn,1,1
if rs_City.recordcount>0 then
for x=1to rs_City.recordcount
%>
sct2obj.options[<%=x%>]=new Option("<%=rs_City("Sorts")%>","1.htm");
<%
rs_City.movenext
next
end if
rs_City.close
set rs_City=nothing%>
}
<%next%>
</script>