<%
'获取分类路径
Function getTextPath(DataFrom,ID)
    Dim rs, sql
    sql = "Select ID,SortName,ParentID from ["&Datapre&"_"&DataFrom&"] where ID="&ID
    set rs=db(sql,2)
    getTextPath = " -> <a href='?SortID="&rs(0)&"'>"&rs(1)&"</a>"
    If rs(2)<>0 Then call getTextPath(DataFrom,rs(2))
    response.Write(getTextPath)
End Function

'获取分类名称
Function getSortName(DataFrom,ID)
    Dim rs, sql
    sql = "Select * from ["&Datapre&"_"&DataFrom&"] where ID="&ID
	set rs=db(sql,2)
    getSortName = rs("SortName")
    rs.Close:Set rs = Nothing
End Function
'递归分类
Function Sortselect(DataFrom,PID,curid)
Dim rs1,sql1,id1,name1,parentid1,sortpath1 
sql1="select ID,ParentID,SortPath,SortName from ["&Datapre&"_"&DataFrom&"] where parentid="&PID&" and Viewflag order by id" 
set rs1=db(sql1,2)
if rs1.eof or rs1.bof then 
response.write"请先添加分类" 
else 
while not rs1.eof 
id1=rs1("id") 
name1=rs1("SortName")
sortpath1=rs1("SortPath") 
response.write ("<option value='"&id1&"|"&SortPath1&"'")
if curid=id1 then response.Write(" selected ")
response.Write(">*"&name1&"</option>") 
parentid1=rs1("parentid") 
call reclass(id1,DataFrom,curid) 
rs1.movenext 
wend 
end if 
rs1.close 
set rs1=nothing 
end Function

sub reclass(id,DataFro,curid) 
'递归调用函数,生成一个类别代码
Dim rs,sql,i,j,id0, SortName0,parentid0,SortPath0,brstr
sql="select ID,ParentID,SortPath,SortName from ["&Datapre&"_"&DataFro&"] where parentid="&id&" and Viewflag order by id" 
set rs=db(sql,2)
i=1 
while not rs.eof 
id0=rs("id") 
SortName0=rs("SortName") 
parentid0=rs("parentid") 
SortPath0=rs("SortPath") 
brstr="" 
for j=1 to Ubound(split(SortPath0,","))-3 
brstr="&nbsp;"&brstr 
next 
response.write ("<option value='"&id0&"|"&SortPath0&"'")
if curid=id0 then response.Write(" selected ")
response.Write(">"&brstr&"|-"&SortName0&"</option>")
call reclass(id0,DataFro,curid) 
rs.movenext 
i=i+1 
wend 
rs.close 
set rs=nothing 
end sub %>