·您的位置: 首页 » 资源教程 » 编程开发 » JAVA、JSP » 类似MSDN CSDN导航树效果,JSP+JAVASCRIPT实现

类似MSDN CSDN导航树效果,JSP+JAVASCRIPT实现

类别: JSP教程  评论数:0 总得分:0
<!-- Tree.jsp -->
<%@ page contentType ="text/html;charset=gb2312" %>
<%@ page import="java.util.*;" %>
<!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="100" id="hiddenframe"></iframe>
<script>
function ExpandNode(ParentNode,ParentId){
var NodeX = eval(ParentNode.id + &acute;_0&acute;);
if (NodeX.style.display == &acute;none&acute;)
{
NodeX.style.display="block";
if (NodeX.loaded == &acute;no&acute;)
{
document.frames[&acute;hiddenframe&acute;].location.replace("subtree.jsp?PID=" + ParentId + "&PNode=" + ParentNode.id);
NodeX.loaded = &acute;yes&acute;;
}
}
else
{
NodeX.style.display=&acute;none&acute;;
}
}
</script>
<CENTER>
<TABLE border="1" width="20%" height="60%">
<TR>
<TD>
<DIV style="OVERFLOW: auto;WIDTH: 100%;HEIGHT: 100%">
<TABLE width="300%">
<TR>
<TD>
<%
java.lang.Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// java.sql.Connection ConnectionX = java.sql.DriverManager.getConnection("jdbc:ODBC:driver={Microsoft Access Driver (*.mdb)};DBQ=D:ResindocexamplesTreetree.mdb","admin", "");
// java.sql.Statement StatementX = ConnectionX.createStatement();
java.sql.ResultSet ResultSetX = java.sql.DriverManager.getConnection("jdbc:ODBC:driver={Microsoft Access Driver (*.mdb)};DBQ=e:resin-2.1.6docexamplesTreetree.mdb","admin", "").createStatement().executeQuery("select *,(select count(*) from tree where parentid = T.id) as children from tree T where parentid = 0");
int i=0;
int children;
int ID;
while (ResultSetX.next())
{
children=ResultSetX.getInt("children");
ID=ResultSetX.getInt("id");
%>
<div id=&acute;Node_<%= i %>&acute;><a href=&acute;#&acute;
<% if (children >0)
{%>
onClick=&acute;ExpandNode(Node_<%= i %>,<%=ID %>)&acute;>+</a>
<%;}
else {%>
>-</a><%;}%>
<a href=&acute;#&acute;
<% if (children >0)
{%>
onDblClick=&acute;ExpandNode(Node_<%= i %>,<%=ID%>)&acute;
<%} %>
>
<%=ResultSetX.getString("remark")%></a>
</div>

<div id=&acute;Node_<%= i %>_0&acute; style=&acute;display: none&acute; loaded=&acute;no&acute;>
正在加载 ...
</div>
<%
i++;
}
%>
</BODY>
</HTML>



<!-- SubTree.jsp -->
<%@ page contentType ="text/html;charset=gb2312" %>
<%@ page import="java.util.*;" %>
<!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>
<%
String ParentNode = request.getParameter("PNode");
int i;
int j;
String nSpace="";
j= ParentNode.length()- ParentNode.replaceAll("_","").length();
for (i=0;i<j;i++)
nSpace = nSpace + " ";
String sHTML ="";
i=0;

java.lang.Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// java.sql.Connection ConnectionX = java.sql.DriverManager.getConnection("jdbc:ODBC:driver={Microsoft Access Driver (*.mdb)};DBQ=D:ResindocexamplesTreetree.mdb","admin", "");
// java.sql.Statement StatementX = ConnectionX.createStatement();
java.sql.ResultSet ResultSetX = java.sql.DriverManager.getConnection("jdbc:ODBC:driver={Microsoft Access Driver (*.mdb)};DBQ=e:resin-2.1.6docexamplesTreetree.mdb","admin", "").createStatement().executeQuery("select *,(select count(*) from tree where parentid =T.id ) as Children from tree T where parentid = " + request.getParameter("PID"));
int children;
int ID;
while (ResultSetX.next())
{ children=ResultSetX.getInt("children");
ID=ResultSetX.getInt("id");
sHTML = sHTML + "<div id=&acute;" + ParentNode + "_" + (i + 1) + "&acute;>" + nSpace + "<a href=&acute;#&acute;";
if (children >0)
sHTML = sHTML + " onClick=&acute;ExpandNode(" + ParentNode + "_" + (i + 1) + "," + ID + ")&acute;>+";
else sHTML = sHTML + ">-";
sHTML = sHTML + "</a>n" + "<a href=&acute;#&acute;";
if (children >0)
sHTML = sHTML + " onDblClick=&acute;ExpandNode(" + ParentNode + "_" + (i + 1) + "," + ID + ")&acute;";
sHTML = sHTML + ">" + ID + ": " + ResultSetX.getString("remark") + "</a></div>";
if (children >0)
sHTML = sHTML + "<div id=&acute;" + ParentNode + "_" + (i + 1) + "_0&acute; style=&acute;display: none&acute; loaded=&acute;no&acute;>" + nSpace + " 正在加载 ...</div>";
%>
<% i++;
}%>
<BODY>
<script>
var x = eval(&acute;parent.&acute; + &acute;<%= ParentNode + "_0"%>&acute; ) ;
x.innerHTML="<%= sHTML %>";
</script>
</BODY>
</HTML>
-= 资 源 教 程 =-
文 章 搜 索
关键词:
类型:
范围:
纯粹空间 softpure.com
Copyright © 2006-2008 暖阳制作 版权所有
QQ: 15242663 (拒绝闲聊)  Email: faisun@sina.com
 纯粹空间 - 韩国酷站|酷站欣赏|教程大全|资源下载|免费博客|美女壁纸|设计素材|技术论坛   Valid XHTML 1.0 Transitional
百度搜索 谷歌搜索 Alexa搜索 | 粤ICP备19116064号-1