實例測試:
表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
循環(huán)結(jié)果:
www.hubro.net/code/class/test.asp
基本上可以滿足一般的需要了!
出處:藍色理想
責(zé)任編輯:moby
上一頁 [ASP]把無限級分類生成數(shù)組 [1] 下一頁
◎進入論壇網(wǎng)絡(luò)編程版塊參加討論
|