??不会吧?这是我以前的一个程序,运行时没有错误:
<!--#include file="../adovbs.inc"-->
<!--#include file="../dbconn/dbconn.asp"-->
<%
function tree(officeid)
sql="select * from officedb where officeparents='"&officeid&"'"
set rs1=conn.Execute(sql)
if rs1.bof or rs1.eof then
else
while rs1.eof=false
%>
<tr><td><input type="button" value=<%=rs1("officename")%> onclick="window.open('discdisp.asp?officeid=<%=rs1("officeid")%>','discdisp','width=640,height=480,toolbar=no,menubar=no')"></td>
<td>
<table>
<%
tree(rs1("officeid"))
%>
</table>
</td></tr>
<%
rs1.movenext
wend
end if
end function
%>
<center>
<table>
<tr>
<%
tree(0)
%>
</tr>
</table>
<table>
<tr>
<td>
<input type="button" value="全体留言" onclick="window.open('discdisp.asp?officeid=0','discdisp','width=640,height=480,toolbar=no,menubar=no')">
哈哈!!!你给分吗~!!
你是呀ASP 还是JAVASCRIPT的呀~!!!
(1)ASP的
表名:BBS
字段
数据类型
说明
ID 自动编号
RootID Int 根帖ID,本身为根帖则RootID = ID
FID Int 父帖ID,上一层帖子的ID,如是根帖则FID = NULL
Level SmallInt 根帖Level=0,其他依据回复的深度递增
Subject Char 主题
SQL 语句(须据此创建记录集 rs):
SELECT *
FROM BBS
ORDER BY BBS.RootID DESC, BBS.Level, BBS.FID, BBS.ID DESC
____________________________________________
显示树形结构的有关语句:
____________________________________________
Level = 0
Response.Write "<ul>"
While NOT rs.EOF
If rs("Level") < level Then
For i = 1 To Level-1
Response.Write "</ul>"
Next
End If
If rs("Level") > level Then
Response.Write "<ul>"
End If
Response.Write "<li>" & rs("Subject") & "</li>"
用函数递归调用。
function tree(id)
if trim(id)=="" then
id=0
end if
sql="select * from table where pid='"&id&"'"
set rs1=conn.Execute(sql)
if rs1.bof or rs1.eof then
else
while rs1.eof=false
%>
<tr><td><%=rs1("name")%></td>
<td>
<table>
<%
tree(rs1("id"))
%>
</table>
</td></tr>
<%
rs1.movenext
wend
end if
end function
源程序如下:
<%@Language=VbScript%>
<%
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open Application("ConnString")
id = "a01"
Set rs1 = conn.Execute ("Select * From task where id='"&id&"'")
function tree(id)
if trim(id)="" then
id=0
end if
sql="select * from task where pid='"&id&"'"
set rs1=conn.Execute(sql)
if rs1.bof or rs1.eof then
else
while rs1.eof=false
%>
<tr><td><%=rs1("id")%></td>
<td>
<table>
<%
tree(rs1("id"))
%>
</table>
</td></tr>
<%
rs1.movenext
wend
end if
end function
tree(rs1("id"))
%>