树行问题?

xyp730000 2003-08-21 11:11:06
各位大侠。为什么我这个没有子层数据。只有第一层数据

<script>
function expand(id){
window.status=eval("s"+id).innerText;
getLight(id);
if(eval("s"+id).href!='')document.frames['nodehref'].location.href=eval("s"+id).href
switch(eval("dir"+id).innerText){//改变"+","-"
case "-":
eval("dir"+id).innerText="+";eval("dir"+id).className='dirclose';document.getElementById("load_"+id).style.display='none';break;
case "+":
eval("dir"+id).innerText="-";eval("dir"+id).className='diropen';document.getElementById("load_"+id).style.display='';break;
default:eval("dir"+id).innerText=".";eval("dir"+id).className='dirNode';
}
if(eval("dir"+id).innerText==".")return;
if(eval("dir"+id).innerText=="+"){if(document.getElementById("t"+id)){eval("t"+id).removeNode(true);return;}}
document.frames['hifm'].location.href="subtree.asp?id="+id
}

function getLight(id){//高亮度显示当前结点
var s=document.getElementsByTagName("SPAN")
var sn=document.getElementById("s"+id)
for(i=0;i<s.length;i++)if(s[i].className=='node')s[i].style.cssText="color:#000000;background-color:#f2f2f2"
sn.style.cssText="color:#000000;background-color:#ffffff;border:1 solid #999999"
}
</script>
<body topmargin="0" leftmargin="0" scroll="no">
<% dim conn,rs
set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.mappath("Collection.mdb") & ";Persist Security Info=False"
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "select *,(select count(*) from indexTable where Parent = theID) as children from indexTable where theID=Parent",conn,1,3
%>
<div align="center">
<center>
<table border="0" width="779" cellspacing="0" cellpadding="0" height=100% bgcolor="#F2F2F2">
<tr>
<td width="260" style="border-right:5 solid #6699cc" valign="top" align="left">
<div id=treedir style="overflow:auto;width:100%;height:100%">
<table border='0' cellspacing='0' cellpadding='0' style='position:relative;left:18;top:20' onselectstart="return false">
<%
do while not rs.eof
if rs("children")<=1 then
s="."
cls="dirNode"
else
s="+"
cls="dirclose"
end if
%>
<tr><td id='node<%=rs("theID")%>' class='td_node' valign=top><span class='<%=cls%>' id='dir<%=rs("theID")%>' onclick='expand(<%=rs("theID")%>)'><%=s%></span><span class='node' id='s<%=rs("theID")%>' onclick='expand(<%=rs("theID")%>)' title='<%=rs("theName")%>' href='<%=rs("theName")%>'><%=rs("theName")%></span></td></tr>
<% if rs("children")>1 then%>
<tr id="load_<%=rs("theID")%>" style="display:none"><td class='td_node'><table border='0' cellspacing='0' cellpadding='0' style='position:relative;left:18;top:0'><tr><td class='td_node'><span class='dirNode'>.</span><span class='load'>Loading...</span></td></tr></table></td></tr>
<%end if%>
<% rs.movenext
loop
%>
</table>
</div>
</td>
<td valign="top" align="left">
<iframe name=nodehref style="border:1 solid #3366cc;width:100%;height:100%;overflow:auto" src="about:blank" frameborder=0 ></iframe>
</td>
</tr>
</table>
</center>
</div>
<%
set rs=nothing
set conn=nothing
%>
<iframe id='hifm' width=0 height=0></iframe>


</body>
...全文
36 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
xyp730000 2003-08-22
  • 打赏
  • 举报
回复
up
flygoocn 2003-08-21
  • 打赏
  • 举报
回复
看你的代码好晕
xyp730000 2003-08-21
  • 打赏
  • 举报
回复
up
fason 2003-08-21
  • 打赏
  • 举报
回复
检查subtree.asp是否有错误,导致数据无法返回

http://fason.nease.net/
Brookes 2003-08-21
  • 打赏
  • 举报
回复
太多了,晕~~~~
xyp730000 2003-08-21
  • 打赏
  • 举报
回复
up
xyp730000 2003-08-21
  • 打赏
  • 举报
回复
没人吗
分不够可以加嘛
我急用啊
xyp730000 2003-08-21
  • 打赏
  • 举报
回复
不行啊
pp4u 2003-08-21
  • 打赏
  • 举报
回复
把sql语句改为"select *,(select count(*) from indexTable where Parent = T.theID) as children from indexTable T where Parent=0 order by Parent"
xyp730000 2003-08-21
  • 打赏
  • 举报
回复
谁能给我改一下。
数据库:Collection.mdb->indexTable->Parent;theID
我的email:xyp730000@sina.com
xyp730000 2003-08-21
  • 打赏
  • 举报
回复
xyp730000@sina.com

下面是:
<% dim conn,rs,s,cls,href
dim nodeid
nodeid=request.querystring("id")
set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.mappath("Collection.mdb") & ";Persist Security Info=False"
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "select *,(select count(*) from indexTable where Parent = theID) as children from indexTable T where Parent="&nodeid&" and id<>"&CInt(nodeid),conn,1,3
dim node_html
node_html="<table id='t"&nodeid&"' border='0' style='position:relative;left:18' cellspacing='0' cellpadding='0'>"
do while not rs.eof
if rs("theID")<>rs("Parent") then
if rs("children")=0 then
s="."
cls="dirNode"
else
s="+"
cls="dirclose"
end if
end if
node_html=node_html&"<tr><td id='node"&rs("theID")&"' class='td_node'><span class='"&cls&"' id='dir"&rs("theID")&"' onclick='expand("&rs("theID")&")'>"&s&"</span><span class='node' id='s"&rs("theID")&"' onclick='expand("&rs("theID")&")' title='"&rs("theName")&"' href='"&rs("theName")&"'>"&rs("theName")&"</span></td></tr>"
if rs("children")>0 then
node_html=node_html&"<tr id='load_"&rs("theID")&"' style='display:none'><td class='td_node'><table border='0' cellspacing='0' cellpadding='0' style='position:relative;left:18;top:0'><tr><td class='td_node'><span class='dirNode'>.</span><span class='load'>Loading...</span></td></tr></table></td></tr>"
end if
rs.movenext
loop
node_html=node_html&"</table>"
set rs=nothing
set rs = Server.CreateObject("ADODB.Recordset")
rs.open "select link from indexTable where theID="&nodeid,conn,1,3
%>
<script>
if(parent.document.getElementById("load_"+"<%=nodeid%>")){
parent.document.getElementById("load_"+"<%=nodeid%>").style.display="none"
parent.document.getElementById("node"+<%=nodeid%>).innerHTML+="<%=node_html%>"
}
</script>
<% set rs=nothing
set conn=nothing
%>
pp4u 2003-08-21
  • 打赏
  • 举报
回复
给个地址,两个页面都给你发过去。。。
pp4u 2003-08-21
  • 打赏
  • 举报
回复
哈,你只有deeptree.asp没有subtree.asp当然不行了。。。

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧