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

<script type="text/javascript"> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>

MSDNCSDN 左边导航树的效果都是在点击父节点时,再发出请求填充其子节点!好像网页只刷新部分! 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=TRIATONPSQL2KE"
  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")
'  adoConnection.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=Test;Data Source=TRIATONPSQL2KE"

  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 parentid = " & parentid ,adoConnection
  response.write  adoRecordset.source
  dim i
  Dim SHTML
  dim parentnode
  parentnode = request.querystring("Pnode")
  dim j
  j= len(parentnode) - len(replace(parentnode,"_",""))
  dim nSpace
  for i=0 to j - 1
      nSpace = nSpace + "&nbsp;&nbsp;"
  next
  i=0
  do until adoRecordset.eof
     shtml = shtml _
             & "<div id='" & parentnode & "_" & i + 1 & "'>" & nSpace _
             & "<a href='#'"
      if adoRecordset.Fields.item("Children").value >0 then
         shtml = shtml & " onClick='ExpandNode(" & parentnode & "_" & i + 1 & "," & adoRecordset.Fields.item("id").value & ")'>+"
      else
         shtml = shtml & ">-"
      end if
      shtml = shtml & "</a>" & "<a href='#'"
      if adoRecordset.Fields.item("Children").value >0 then
         shtml = shtml & "onDblClick='ExpandNode(" & parentnode & "_" & i + 1 & "," & adoRecordset.Fields.item("id").value & ")'"
      end if
      shtml = shtml & ">" & adoRecordset.Fields.item("id").value & ": " &  adoRecordset.Fields.item("remark").value & "</a></div>"
      if adoRecordset.Fields.item("Children").value >0 then
         shtml = shtml & "<div id='" & parentnode & "_" & i + 1 & "_0' style='display: none' loaded='no'>" & nSpace & "&nbsp;&nbsp;正在加载 ...</div>"
      end if
      i=i+1
      adoRecordset.MoveNext
  loop
  adoRecordset.close
  set adoRecordset = nothing
  adoConnection.close
  set adoConnection = nothing
'response.write shtml
%>
<script>
   var x = eval('parent.' + '<% =request.querystring("Pnode") & "_0"%>' ) ;
   x.innerHTML="<% =shtml %>";
</script>
</BODY>
</HTML>

表结构:
Tree(id,parentid,remark)

 

 

<script type="text/javascript"> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Visual Basic 6.0是一种广泛使用的企业级编程语言和开发环境,它具备丰富的功能和易用的界面,适用于开发各种类型的应用程序。作为企业版,它提供了更多的功能和工具,帮助开发人员提高开发效率和质量。 在开发过程中,我们可以利用Visual Basic 6.0的各种特性和库来创建用户界面,处理数据和实现各种操作。它支持用户界面的可视化设计,可以通过拖放控件和设置属性来快速构建各种窗体和用户界面。同时,它也提供了丰富的控件库,包括按钮、文本框、列表框等,以便开发人员可以根据需求选择合适的控件。 Visual Basic 6.0还具有强大的数据处理功能,可以连接到各种数据库,如Microsoft SQL Server、Oracle等,同时支持SQL查询操作。通过它,我们可以轻松地读取、更新和删除数据库中的数据,从而实现与数据库的高效交互。 在开发过程中,MSDNCSDN是非常有用的资源。MSDN是Microsoft Developer Network的缩写,是一个丰富的技术文档和资源库,提供了关于Visual Basic 6.0的各种教程、示例代码和开发工具。而CSDN是中国软件开发者社区的缩写,也是一个较大的开发者社区,有很多经验丰富的开发者和专家可以提供帮助和解答问题。 总之,Visual Basic 6.0是一个强大的企业级开发工具,具备丰富的功能和易用的界面,可以帮助开发人员快速构建各种类型的应用程序。同时,MSDNCSDN等资源库也为开发人员提供了巨大的帮助和支持,使开发过程更加顺利和高效。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值