javascript

位置:IT落伍者 >> javascript >> 浏览文章

JSP+JavaScript实现类似MSDN CSDN导航树效果代码


发布日期:2024年07月09日
 
JSP+JavaScript实现类似MSDN CSDN导航树效果代码

<! Treejsp >
<%@ page contentType ="text/html;charset=gb" %>
<%@ page import="javautil*;" %>
<!DOCTYPE HTML PUBLIC "//WC//DTD HTML 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="%" height="" id="hiddenframe"></iframe>
<script>
function ExpandNode(ParentNodeParentId){
var NodeX = eval(ParentNodeid + _);
if (NodeXstyledisplay == none)
{
NodeXstyledisplay="block";
if (NodeXloaded == no)
{
documentframes[hiddenframe]locationreplace("subtreejsp?PID=" + ParentId + "&PNode=" + ParentNodeid);
NodeXloaded = yes;
}
}
else
{
NodeXstyledisplay=none;
}
}
</script>
<CENTER>
<TABLE border="" width="%" height="%">
<TR>
<TD>
<DIV style="OVERFLOW: auto;WIDTH: %;HEIGHT: %">
<TABLE width="%">
<TR>
<TD>
<%
javalangClassforName("sunjdbcodbcJdbcOdbcDriver");
// javasqlConnection ConnectionX = javasqlDriverManagergetConnection("jdbc:ODBC:driver={Microsoft Access Driver (*mdb)};DBQ=D:\\Resin\\doc\\examples\\Tree\\treemdb""admin" "");
// javasqlStatement StatementX = ConnectionXcreateStatement();
javasqlResultSet ResultSetX = javasqlDriverManagergetConnection("jdbc:ODBC:driver={Microsoft Access Driver (*mdb)};DBQ=e:\\resin\\doc\\examples\\Tree\\treemdb""admin" "")createStatement()executeQuery("select *(select count(*) from tree where parentid = Tid) as children from tree T where parentid = ");
int i=;
int children;
int ID;
while (ResultSetXnext())
{
children=ResultSetXgetInt("children");
ID=ResultSetXgetInt("id");
%>
<div id=Node_<%= i %>><a #
<% if (children >)
{%>
onClick=ExpandNode(Node_<%= i %><%=ID %>)>+</a>
<%;}
else {%>
></a><%;}%>
<a #
<% if (children >)
{%>
onDblClick=ExpandNode(Node_<%= i %><%=ID%>)
<%} %>
>
<%=ResultSetXgetString("remark")%></a>
</div>

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

<! SubTreejsp >
<%@ page contentType ="text/html;charset=gb" %>
<%@ page import="javautil*;" %>
<!DOCTYPE HTML PUBLIC "//WC//DTD HTML 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 = requestgetParameter("PNode");
int i;
int j;
String nSpace="";
j= ParentNodelength() ParentNodereplaceAll("_""")length();
for (i=;i<j;i++)
nSpace = nSpace + "&nbsp;&nbsp;";
String sHTML ="";
i=;

javalangClassforName("sunjdbcodbcJdbcOdbcDriver");
// javasqlConnection ConnectionX = javasqlDriverManagergetConnection("jdbc:ODBC:driver={Microsoft Access Driver (*mdb)};DBQ=D:\\Resin\\doc\\examples\\Tree\\treemdb""admin" "");
// javasqlStatement StatementX = ConnectionXcreateStatement();
javasqlResultSet ResultSetX = javasqlDriverManagergetConnection("jdbc:ODBC:driver={Microsoft Access Driver (*mdb)};DBQ=e:\\resin\\doc\\examples\\Tree\\treemdb""admin" "")createStatement()executeQuery("select *(select count(*) from tree where parentid =Tid ) as Children from tree T where parentid = " + requestgetParameter("PID"));
int children;
int ID;
while (ResultSetXnext())
{ children=ResultSetXgetInt("children");
ID=ResultSetXgetInt("id");
sHTML = sHTML + "<div id=" + ParentNode + "_" + (i + ) + ">" + nSpace + "<a #";
if (children >)
sHTML = sHTML + " onClick=ExpandNode(" + ParentNode + "_" + (i + ) + "" + ID + ")>+";
else sHTML = sHTML + ">";
sHTML = sHTML + "</a>\\n" + "<a #";
if (children >)
sHTML = sHTML + " onDblClick=ExpandNode(" + ParentNode + "_" + (i + ) + "" + ID + ")";
sHTML = sHTML + ">" + ID + ": " + ResultSetXgetString("remark") + "</a></div>";
if (children >)
sHTML = sHTML + "<div id=" + ParentNode + "_" + (i + ) + "_ style=display: none loaded=no>" + nSpace + "&nbsp;&nbsp;正在加载 </div>";
%>
<% i++;
}%>
<BODY>
<script>
var x = eval(parent + <%= ParentNode + "_"%> ) ;
xinnerHTML="<%= sHTML %>";
</script>
</BODY>
</HTML>

               

上一篇:如何让页面加载完成后执行js

下一篇:Jquery获取页面传值