asp 树状目录结构
发布网友
发布时间:2022-04-12 17:45
我来回答
共4个回答
热心网友
时间:2022-04-12 19:15
<%
dim a
a=1
Set rs= Server.CreateObject("ADODB.Recordset")
sql="select * from Yt order by whid asc"
rs.open sql,conn,1,1
do while not rs.eof
response.write "<DIV style='PADDING-LEFT: "&a*rs("whbh_parent")&"em'>"&rs("whname")&"</DIV>"
rs.movenext
loop
rs.close
set rs=nothing
%>
热心网友
时间:2022-04-12 20:33
如果数据不多的话,一次性读出所有数据,输出给客户端JS以数组的形式处理
热心网友
时间:2022-04-12 22:07
表的结构:
--------------------------
id cname fid
1 根目录1 0
2 一级目录 1
3 根目录2 0
4 二级目录 2
5 *目录 4
-------------------------
style:
.div_child{padding:0 0 0 14px;}
---------------------
asp:
function showchild(fid) '显示此目录下的子目录
Set rs= Server.CreateObject("ADODB.Recordset")
sql="select * from fid="&fid
rs.open sql,conn,1,1
if not rs.eof then
for i=1 to rs.recordcount
response.write "<div class=""div_child""><div>"&rs("cname")&"</div>"
showchild rs("id")
response.write "</div>"&chr(13)
rs.movenext
next
end if
set rs=nothing
end function
在需要调用的时候直接<%showchild 0%>
热心网友
时间:2022-04-12 23:59
<%
dim
a
a=1
Set
rs=
Server.CreateObject("ADODB.Recordset")
sql="select
*
from
Yt
order
by
whid
asc"
rs.open
sql,conn,1,1
do
while
not
rs.eof
response.write
"<DIV
style='PADDING-LEFT:
"&a*rs("whbh_parent")&"em'>"&rs("whname")&"</DIV>"
rs.movenext
loop
rs.close
set
rs=nothing
%>