# asp高手请进！递规问题 请高手知道

WiseDragon 2006-06-27 08:59:01
category是个2维数组
category(0,i)是分类编号, category(1,i)分类名称, category(2,i)是上级分类编号
Sub SubCategory(parentId)
dim i
if count>0 then
for i=0 to count-1
if category(2,i)=parentId then
Response.Write("<option value='"& category(0,i) &"'>"& category(1,i)&"</option>")
call SubCategory(category(0,i))
end if
next
end if
End Sub

A
a1
a1
a3
B
b1
b2

A
---a1
---a2
B
---b2
---b2

...全文
89 点赞 收藏 2

2 条回复

indexroot 2006-06-28
Dim category(2,10)
count=11

category(0,0)=0
category(1,0)="ROOT"
category(2,0)=-1

category(0,1)=1
category(1,1)="A"
category(2,1)=0

category(0,2)=2
category(1,2)="B"
category(2,2)=0

category(0,3)=3
category(1,3)="A1"
category(2,3)=1

category(0,4)=4
category(1,4)="A2"
category(2,4)=1

category(0,5)=5
category(1,5)="A3"
category(2,5)=1

category(0,6)=6
category(1,6)="B1"
category(2,6)=2

category(0,7)=7
category(1,7)="B2"
category(2,7)=2

category(0,8)=8
category(1,8)="B3"
category(2,8)=2

category(0,9)=9
category(1,9)="B11"
category(2,9)=6

category(0,10)=9
category(1,10)="B12"
category(2,10)=6

Sub SubCategory(parentId,level)
dim i
if count>0 then
for i=0 to count-1
if category(2,i)=parentId then

Response.Write("<option value='"& category(0,i) &"'>" & showLine(level) & category(1,i)&"</option>")
call SubCategory(category(0,i),level+1)
end if
next

end if
End Sub

Function showLine(n)
for i=1 to n
s=s&"---"
next
showLine=s
End Function

Response.Write("<select>")
call SubCategory(-1,-1)
Response.Write("</select>")

WiseDragon 2006-06-28

ASP

2.8w+

ASP即Active Server Pages，是Microsoft公司开发的服务器端脚本环境。

2006-06-27 08:59