清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | 程序调用: <% Dim rss,u Set rss = Server.CreateObject( "Adodb.RecordSet" ) rss.Open "select ID,fatherID,name from [Select_Menu] order by id" ,Conn,1,1 Response.Write "<select name='FatherID'><option value='0'> - 0.顶级菜单</option>" &GetListTree& "<select>" rss.Close %> 数据库结构: Select_Menu: id,fatherid,name fatherid=0,置为顶级菜单 函数: <% '无限级分类菜单树Select输出函数 Function GetListTree Dim Result,i Redim u(rss.RecordCount,3) for i = 1 to rss.RecordCount u(i - 1,0) = rss( "ID" ) u(i - 1,1) = rss( "fatherID" ) u(i - 1,2) = rss( "Name" ) rss.MoveNext next 'rss.moveFirst for i = 0 to uBound(u) - 1 If Int(u(i,1)) = 0 Then '如果ID=FatherID则定位其父类 if u(i,0)=fatherid then selected= "Selected" else selected= "" end if Result = Result & "<option " &Selected& " value='" & u(i,0) & "'> ◢ " & u (i ,2) & "</option>" & vbcrlf & SunSorts(u(i ,0), 0) End If next GetListTree = Result End Function Function SunSorts(who,SunLevel) Dim selected Dim Result,i,sp,EndID for i = 0 to SunLevel sp = sp & "--" next for i = 0 to uBound(u) - 1 If Int(u(i,1)) = Int(who) Then EndID = u(i ,0) else EndID = fatherID End If next for i = 0 to uBound(u) - 1 If Int(u(i,1)) = Int(who) Then If u(i ,0) - EndID = 0 Then Result = Result & "<option " &selected& " value='" & u(i,0) & "'>" & sp & "┕" & u(i ,2) & "</option>" & vbcrlf & SunSorts(u(i ,0),SunLevel + 1) Else Result = Result & "<option " &selected& " value='" & u(i,0) & "'>" & sp & "┝ " & u(i ,2) & "</option>" & vbcrlf & SunSorts(u(i ,0),SunLevel + 1) End If End If next SunSorts = Result End Function %> |