类似 MSDN CSDN 左边导航树效果的实现! [JavaScript + ASP][1]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 playyuer 的 blog

msdn 和csdn 左边导航树的效果都是在点击父节点时,再发出请求填充其子节点!好像网页只刷新部分! javascript + [asp +  access] 实现

源程序下载: http://www.triaton.com.cn/private/zip/tree.zip

<!-- tree.asp -->
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title> new document </title>
<meta name="generator" content="editplus">
<meta name="author" content="">
<meta name="keywords" content="">
<meta name="description" content="">
</head>
<body>
<iframe width="100%" height="30" id="hiddenframe"></iframe>
<script>
function expandnode(parentnode,parentid){
var nodex = eval(parentnode.id + '_0');
if (nodex.style.display == 'none')
   {
    nodex.style.display="block";
    if (nodex.loaded == 'no')
       {
        document.frames['hiddenframe'].location.replace("http://localhost/dvbbs/subtree.asp?pid=" + parentid + "&pnode=" + parentnode.id);
        nodex.loaded = 'yes';
      }
   }
else
   {
    nodex.style.display='none';
   }
}
</script>
<center>
<table border="1" width="20%" height="60%">
   <tr>
      <td>
         <div style="overflow: auto;width: 100%;height:100%">
            <table width =300%>
               <tr>
                   <td>
<%
  dim adoconnection
  set adoconnection = server.createobject("adodb.connection")
  'adoconnection.open "provider=sqloledb.1;persist security info=false;user id=sa;initial catalog=test;data source=triaton\psql2ke"
  adoconnection.open "provider=microsoft.jet.oledb.4.0;data source=" & server.mappath("/dvbbs") & "\tree.mdb;persist security info=false"
  dim adorecordset
  set adorecordset = server.createobject("adodb.recordset")
  adorecordset.open "select *,(select count(*) from tree where parentid = t.id) as children from tree t where rootid = id ",adoconnection
  dim i
  i=0
  do until adorecordset.eof
 %>
<div id='node_<% = i %>'>
     <a href='#'
<%  if adorecordset.fields.item("children").value >0 then %>
        onclick='expandnode(node_<% = i %>,<% =adorecordset.fields.item("id").value%>)'>+</a>
  <% else %>
        >-</a>
  <% end if%>
<a href='#' ondblclick='expandnode(node_<% = i %>,<% =adorecordset.fields.item("id").value%>)'><% =adorecordset.fields.item("remark").value%></a>
</div>
<div id='node_<% = i %>_0' style='display: none' loaded='no'>
      &nbsp;&nbsp;正在加载 ...
     </div>
<%   i=i+1
     adorecordset.movenext
  loop
  adorecordset.close
  set adorecordset = nothing
  adoconnection.close
  set adoconnection = nothing
%>
                   </td>
               </tr>
            </table>
         </div>
      </td>
   </tr>
</table>
</center>
</body>
</html>

 

<!-- subtree.asp -->
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title> new document </title>
<meta name="generator" content="editplus">
<meta name="author" content="">
<meta name="keywords" content="">
<meta name="description" content="">
</head>
<body>
<%
  dim parentid
  parentid = request.querystring("pid")
  parentnode = request.querystring("parentnode")
  dim adoconnection
  set adoconnection = server.createobject("adodb.connection")

本文关键:Tree,树,iFrame
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top