编写一个含二级目录的源码(Asp+JavaScript)

2018-09-06 10:59

阅读:622

  **********************(一)打开记录集,创建数组,把记录集的值赋给数组.
<%
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))%>,<%=trim(Rs(BoardId))%>);
<%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>
**********************(二)显示分组,并编写列表框的OnChange事件.
<%setRs=server.CreateObject(adodb.recordset)
Sql=select*fromBookClassorderbyClassIddesc
Rs.openSql,cn,1,1
ifRs.eofandRs.bofthen
response.write请先添加总类。
response.end
else%>
<selectname=ClassIdonChange=changelocation(document.form1.ClassId.options[document.form1.ClassId.selectedIndex].value)>
<optionselectedvalue=>==请选择大类==</option>
<%dountilRs.eof%>
<optionvalue=<%=trim(Rs(ClassId))%>><%=trim(Rs(ClassName))%></option>
<%Rs.movenext
loop
endif
Rs.close
setRs=nothing%>
</select>
<selectname=BoardId><optionselectedvalue=>==请选择小类==</option>
</select>


评论


亲,登录后才可以留言!