01
<%
02
03
Function SelectList(ID, LeftText)
04
Dim Rs, Sql, ChildCount
05
Set Rs = Server.CreateObject("Adodb.Recordset")
06
Sql = "Select ID,ColumnName from Column where ParentID = " & ID &" "
07
Sql = Sql & "Order by ID ASC"
08
Rs.Open Sql, Conn, 1, 1
09
Do While Not Rs.EOF
10
ChildCount = Conn.Execute("Select Count(*) from Column where ParentID = " & Rs(0))(0)
11
Response.Write("<option value=""" & Rs(0) & """>" & LeftText & Rs(1) & "</option>" & vbCrLf)
12
If ChildCount > 0 Then Call SelectList(Rs(0), LeftText & " ┣ ")
13
Rs.MoveNext
14
Loop
15
Rs.Close
16
Set Rs = Nothing
17
End Function
18
%>(鼠標移到代碼上去,在代碼的頂部會出現四個圖標,第一個是查看源代碼,第二個是復制代碼,第三個是打印代碼,第四個是幫助)
調用方法:
vIEw source
print?
1
<%
2
Response.Write("<select name=""SortID"" id=""SortID"">" & vbCrLf)
3
Call SelectList(0, "")
4
Response.Write("</select>" & vbCrLf)
5
%>