实例测试:
表CLASS
字段 id:自动编号 classname:名称 pid:父ID
test.asp
<!--#include file="class.asp"--> <% Set conn=Server.CreateObject("ADODB.connection") Set Rs = Server.CreateObject("ADODB.Recordset") StrDSN = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" StrDSN = StrDSN & Server.MapPath("test.mdb") conn.Open strDSN
function ins(num) str="" for ii=1 to num str=str&"|-" next ins=str end function
set aa=new classlist aa.id="id" aa.classname="classname" aa.pid="pid" aa.db_name="class" list=aa.arrylist()
response.write "<table border=1><tr><td>ID</td><td>名称</td><td>第几类</td></tr>" for j=0 to ubound(list,2) response.write "<tr><td>"&list(0,j)&"</td><td>"&list(1,j)&"</td><td>"&list(2,j)&"</td></tr>" next response.write "</table>" 'response.write list(1,3) %> <select name=""> <% for i=0 to ubound(list,2)%> <option value=""><% response.write ins(list(2,i)) response.write list(1,i)%></option> <%next%> </select
循环结果:
www.hubro.net/code/class/test.asp
基本上可以满足一般的需要了!
出处:蓝色理想
责任编辑:moby
上一页 [ASP]把无限级分类生成数组 [1] 下一页
◎进入论坛网络编程版块参加讨论
|