<script language = "JavaScript">
<%
Set Rs = Server.CreateObject("Adodb.Recordset")
Rs.Open "SELECt * FROM products_category_sub ORDER BY sub_id asc", conn, 1, 1
%>
var onecount;
onecount=0;
subcat = new Array();
<%
i = 0
Do While Not Rs.EOF
%>
subcat[<%=i%>] = new Array("<%= Trim(Rs("sub_title"))%>","<%= Rs("main_id")%>","<%= Rs("sub_id")%>");
<%
i = i + 1
Rs.MoveNext
Loop
Rs.Close
%>
onecount=<%=i%>;
function changelocation(locationid,formname)
{
formname.sub_id.length = 0;
var locationid = locationid;
var i;
for (i = 0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
formname.sub_id.options[formname.sub_id.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
</script>
……
……
……
<select name="main_id" id="main_id" onchange="changelocation(document.products_add.main_id.options[document.products_add.main_id.selectedIndex].value,document.products_add)">
<%
i = 0
Set RsBig = Conn.Execute("SELECT * FROM products_category_main ORDER BY order_id")
Do While Not RsBig.EOF
If i = 0 Then main_id = RsBig(0)
Response.Write("<option value="""&RsBig(0)&""">"&RsBig(1)&"</option>")
i = i + 1
RsBig.MoveNext
Loop
Set RsBig = Nothing
%>
</select>
<select name="sub_id" id="sub_id">
<%
If main_id <> "" Then
Set RsSmall = Conn.Execute("SELECT * FROM products_category_sub WHERe main_id = "&main_id)
Do While Not RsSmall.EOF
Response.Write("<option value="""&RsSmall(0)&""">"&RsSmall(1)&"</option>")
RsSmall.MoveNext
Loop
End If
Set RsSmall = Nothing
%>
</select>