<% '参数LeftText可以很方便的区分父栏目与子栏目之间的'错位'关系 Function SelectList(ID, LeftText) Dim Rs, Sql, ChildCount Set Rs = Server.CreateObject("Adodb.Recordset") Sql = "Select ID,ColumnName from Column where ParentID = " & ID & " " '起始栏目 Sql = Sql & "Order by ID ASC" Rs.Open Sql, Conn, 1, 1 Do While Not Rs.EOF ChildCount = Conn.Execute("Select Count(*) from Column where ParentID = " & Rs(0))(0) '子栏目数量 Response.Write("<option value=""" & Rs(0) & """>" & LeftText & Rs(1) & "</option>" & vbCrLf) If ChildCount > 0 Then Call SelectList(Rs(0), LeftText & " ┣ ") '递归 Rs.MoveNext Loop Rs.Close Set Rs = Nothing End Function %>(鼠标移到代码上去,在代码的顶部会出现四个图标,第一个是查看源代码,第二个是复制代码,第三个是打印代码,第四个是帮助)
调用方法:
<% Response.Write("<select name=""SortID"" id=""SortID"">" & vbCrLf) Call SelectList(0, "") Response.Write("</select>" & vbCrLf) %>(鼠标移到代码上去,在代码的顶部会出现四个图标,第一个是查看源代码,第二个是复制代码,第三个是打印代码,第四个是帮助)