************************(1) Open the record set, create an array, and assign the value of the record set to the array.
<%
Dimcount
setRs=server.createobject("adodb.recordset")
Sql="select*fromBookBoardorderbyClassIddesc"
Rs.openSql,cn,1,1%>
<scriptlanguage="JavaScript">
varonecount;
onecount=0;
subcat=newArray();
<%count=0
dowhilenotRs.eof%>
subcat[<%=count%>]=newArray("<%=trim(Rs("BoardName"))%>","<%=trim(Rs("ClassId"))%>");
<%count=count+1
Rs.movenext
loop
Rs.close%>
onecount=<%=count%>;
functionchangelocation(locationid)
{document.form1.BoardId.length=0;
varlocationid=locationid;
vari;
for(i=0;i<onecount;i++)
{if(subcat[i][1]==locationid)
{document.form1.BoardId.options[document.form1.BoardId.length]=newOption(subcat[i][0],subcat[i][2]);
}}}
</script>
************************(II) Display grouping and write the OnChange event of the list box.
<%setRs=server.CreateObject("adodb.recordset")
Sql="select*fromBookClassorderbyClassIddesc"
Rs.openSql,cn,1,1
ifRs.eofandRs.bofthen
response.write "Please add the total class first."
response.end
else%>
<selectname="ClassId"onChange="changelocation(document.form1.ClassId.options[document.form1.ClassId.selectedIndex].value)">
<optionselectedvalue="">==Please select the major category==</option>
<%dountilRs.eof%>
<optionvalue="<%=trim(Rs("ClassId"))%>"><%=trim(Rs("ClassName"))%></option>
<%Rs.movenext
loop
endif
Rs.close
setRs=nothing%>
</select>
<selectname="BoardId"><optionselectedvalue="">==Please select subcategory==</option>
</select>