写了一个三层动态读取文件夹的下拉菜单的例子,供大家参考!
<%
'得到文件夹路径。注意设置文件名字
urlpath=server.mappath("\book")
set fsobrowse=createobject("scripting.filesystemobject")
'设置文件夹路径
if request("path")="" then
lpath=urlpath&"\"
else
lpath=request("path")&"\"
end if
%>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<meta http-equiv=pragma content=no-cache>
<title>中国国际航空公司</title>
<link rel="stylesheet" href="news.css">
<script language="javascript1.2">
ns4 = (document.layers) ? 1 : 0;
ie4 = (document.all) ? 1 : 0;
ver4 = (ns4 ie4) ? 1 : 0;
if (ver4) {
with (document) {
write("<style type='text/css'>");
if (ns4) {
write(".parent {position:absolute; visibility:visible}");
write(".child {position:absolute; visibility:visible}");
write(".regular {position:absolute; visibility:visible}")
}
else {
write(".child {display:none}")
}
write("</style>");
}
}
function getindex(el) {
ind = null;
for (i=0; i<document.layers.length; i++) {
whichel = document.layers[i];
if (whichel.id == el) {
ind = i;
break;
}
}
return ind;
}
function arrange() {
nexty = document.layers[firstind].pagey +document.layers[firstind].document.height;
for (i=firstind+1; i<document.layers.length; i++) {
whichel = document.layers[i];
if (whichel.visibility != "hide") {
whichel.pagey = nexty;
nexty += whichel.document.height;
}
}
}
function initit(){
if (!ver4) return;
if (ns4) {
for (i=0; i<document.layers.length; i++) {
whichel = document.layers[i];
if (whichel.id.indexof("child") != -1) whichel.visibility = "hide";
}
arrange();
}
else {
divcoll = document.all.tags("div");
for (i=0; i<divcoll.length; i++) {
whichel = divcoll(i);
if (whichel.classname == "child") whichel.style.display = "none";
}
}
}
function expandit(el) {
if (!ver4) return;
if (ie4) {
whichel = eval(el + "child");
if (whichel.style.display == "none") {
whichel.style.display = "block";
}
else {
whichel.style.display = "none";
}
}
else {
whichel = eval("document." + el + "child");
if (whichel.visibility == "hide") {
whichel.visibility = "show";
}
else {
whichel.visibility = "hide";
}
arrange();
}
}
onload = initit;
</script>
</head>
<body bgcolor="#ffffff" topmargin="0" leftmargin="0">
<table width="248" border="0" cellspacing="0" cellpadding="0" align="left">
<tr>
<td>
<%
'处理第一层文件目录
dim thefolder,thesubfolders
if fsobrowse.folderexists(lpath)then
set thefolder=fsobrowse.getfolder(lpath)
set thesubfolders=thefolder.subfolders
'循环输出第一层文件
i=1
for each x in thesubfolders
k="kb"&i
parent=k&"parent"
i=i+1
%>
<div id="<%=parent%>" class="parent"> <a href="#" onclick="expandit('<%=k%>'); return false"><img alt=三层动态下来菜单的例子,供大家参考 src="i_option.gif" width="20" height="16" border="0"><%=x.name%></a></div>
<%'处理第二层文件
onepath=lpath&x.name&"\"
if fsobrowse.folderexists(onepath) then
set childthefolder=fsobrowse.getfolder(onepath)
set childthesubfolders=childthefolder.subfolders
child=k&"child"
%>
<div id="<%=child%>" class="child">
<%'循环输出第二层文件
m=1
for each y in childthesubfolders
k="kb"&i&m
m=m+1
%>
<img alt=三层动态下来菜单的例子,供大家参考 src="filebox.gif" width="19" height="13"><a href="#" onclick="expandit('<%=k%>'); return false"><%=y.name%></a><br>
<%
'处理第三层文件
twopath=onepath&y.name&"\"
if fsobrowse.folderexists(twopath) then
set gthefolder=fsobrowse.getfolder(twopath)
set gthesubfolders=gthefolder.subfolders
child=k&"child"
%>
<div id="<%=child%>" class="child">
<%
'循环输出第三层文件
for each z in gthesubfolders
%>
<img alt=三层动态下来菜单的例子,供大家参考 src="filebox.gif" width="19" height="13"><%=z.name%><br>
<%
next
%>
</div>
<%
end if
%>
<%
next
%>
</div>
<%
end if
%>
<%
next
end if
%>
</td>
</tr>
</table>
</body>
</html>
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器