首页 > 编程 > JSP > 正文

用JSP实现类似资源管理器式的文件与目录的折叠(代码示例)

2024-09-05 00:19:15
字体:
来源:转载
供稿:网友
<%@ page import = "sqldata" %>
<%@ page import="java.sql.*" %>
<%@ page contenttype="text/html;charset=gb2312" %>
<jsp:usebean id="sqlbean" class="sqldata" scope="session"/>
<html>
<body background="../images/back.jpg">

<p align="center"><font size="6" face="楷体_gb2312">毛泽东思想概论</font></p>
<%
string aa,bb,cc,dd,ee,ff;
resultset rs=sqlbean.executequery("select * from maogai");
int i=1,j=0;
while(rs.next())
{
aa=rs.getstring("sectiontype");
bb=rs.getstring("sectionname");
cc=rs.getstring("indexfile");
ee=rs.getstring("zipfile");
ff=rs.getstring("onlinefile");
dd=rs.getstring("sessionid");
if(aa.indexof('章')>-1)
{
if(j==1)
{
i=i+1;
out.println("</table></div>");
}
j=0;
out.println(" ");
out.println("<div align='center'>");
out.println("<center>");
out.println("<table border='0' width='90%' height='0' cellspacing='0' cellpadding='0'>");
out.println("<tr>");
out.println("<td height='0'><img name='img"+string.valueof(i)+"' border='0' src='../images/fclosed.gif' onclick='showandhide(div"+string.valueof(i)+","+"img"+string.valueof(i)+")'>");
out.print(bb+"</td></tr></table></center></div>");
}
else 
{
if(j==0)
{
j=1;
out.println("<div style='display:none' id=div"+string.valueof(i)+" align='center'>");
out.println("<center>");
out.println("<table border='0' width='90%' height='0' cellspacing='0' cellpadding='0'>");
out.println("<tr><td height='30'>    <img border='0' src='../images/file.gif'>");
out.print("<a href='windowsopen.jsp?indexfile=maogai/"+cc+"&sessionid="+dd+"&zipfile="+ee+"&onlinefile="+ff+"'>"+bb+"</a></td></tr>");
}
else
{
out.println("<tr><td height='30'>    <img border='0' src='../images/file.gif'>");
out.print("<a href='windowsopen.jsp?indexfile=maogai/"+cc+"&sessionid="+dd+"&zipfile="+ee+"&onlinefile="+ff+"'>"+bb+"</a></td></tr>");
}
}

}
%>
</body>
</html>
<script language=javascript>
function showandhide(divname,imgname)
{
if (divname.style.display == "block") 
{
divname.style.display = "none";
imgname.src="../images/fclosed.gif";
self.focus();

else 
{
divname.style.display = "block";
imgname.src="../images/fopen.gif";
self.focus();
}
}
</script> 
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表