加兩個(gè)字段,一個(gè)是父ID,如果是頂層,父ID就為0,一個(gè)是是否有下級(jí),0元1有,一個(gè)函數(shù)就可解決,在函數(shù)中間調(diào)用本函數(shù),找出了父層,再找他是否有下級(jí),如果有,再找父ID為本ID的欄目
'==================================================
'過程名:listecityclass
'作 用:顯示系統(tǒng)分類
'參 數(shù):id ------ 要匹配的系統(tǒng)ID
'==================================================
Sub listecityclass(id)
dim F_reco,F_total,F_n,F_classid,F_classname,F_classlayer
set F_reco=Server.CreateObject("ADODB.Recordset")
F_reco.Open "select classid,classname,classlayer from ws_ecityclass where classparent=0 and classlist=0 order by classorder Asc",conn,1,1
F_total=F_reco.recordcount
if F_total>0 then
for F_n=1 to F_total
format_i=1
F_classid=F_reco(0)
F_classname=F_reco(1)
F_classlayer=F_reco(2)
response.write " if F_classlayer=0 then response.write " value=" & F_classid
if id=F_classid then response.write " selected"
response.write ">" & F_classname & ""
if F_classlayer=1 then call listecityclass_(id,F_classid) '調(diào)用另一個(gè)函數(shù),在下面
F_reco.movenext
next
end if
F_reco.close : set F_reco=nothing
End Sub
Sub listecityclass_(id,iid)
dim F_reco,F_total,F_n,F_m,F_classid,F_classname,F_classlayer
set F_reco=Server.CreateObject("ADODB.Recordset")
F_reco.Open "select classid,classname,classlayer from ws_ecityclass where classparent="&iid&" and classlist=0 order by classorder Asc",conn,1,1
F_total=F_reco.recordcount
if F_total>0 then
for F_n=1 to F_total
F_classid=F_reco(0)
F_classname=F_reco(1)
F_classlayer=F_reco(2)
format_i=format_i+1
response.write " if F_classlayer=0 then response.write " value=" & F_classid
if id=F_classid then response.write " selected"
response.write ">"
for F_m=format_i to 2 step -1
response.write " "
if F_m=2 then
if F_n=
更多信息請(qǐng)查看IT技術(shù)專欄