<!--#include file="conn.asp" --> <% dim rs dim sql dim count sql = "select * from Small order by ID 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("Small"))%>","<%= trim(rs("Big"))%>","<%= trim(rs("Small"))%>"); <% count = count + 1 rs.movenext loop rs.close %> onecount=<%=count%>;
function changelocation(locationid) { document.myform.SmallClassName.length = 1; var locationid=locationid; var i; for (i=0;i < onecount; i++) { if (subcat[i][1] == locationid) { document.myform.SmallClassName.options[document.myform.SmallClassName.length] = new Option(subcat[i][0], subcat[i][2]); } } }
</script> <TD width="622"> <% sql = "select * from Big" rs.open sql,conn,1,1 if rs.eof and rs.bof then response.write "请先添加栏目。" else %> <select name="BigClassName" onChange="changelocation(document.myform.BigClassName.options[document.myform.BigClassName.selectedIndex].value)" size="1"> <option selected value="<%=trim(rs("Big"))%>"><%=trim(rs("Big"))%></option> <% dim selclass sel rs.movenext do while not rs.eof %> <option value="<%=trim(rs("Big"))%>"><%=trim(rs("Big"))%></option> <% rs.movenext loop end if rs.close %> </select> <select name="SmallClassName"> <option value="" selected>请选择小类</option> <% sql="select * from Small where Big='" & selclass & "'" rs.open sql,conn,1,1 if not(rs.eof and rs.bof) then %> <option value="<%=rs("Small")%>"><%=rs("Small")%></option> <% rs.movenext do while not rs.eof%> <option value="<%=rs("Small")%>"><%=rs("Small")%></option> <% rs.movenext loop end if rs.close %> </select> </strong> |