当前位置:编程学习 > asp >>

三层动态下来菜单的例子,供大家参考!

答案:写了一个三层动态读取文件夹的下拉菜单的例子,供大家参考!
<%
'得到文件夹路径。注意设置文件名字
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=>
<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=>        <%'处理第二层文件
          onepath=lpath&x.Name&"\"
          if fsoBrowse.FolderExists(onepath) then
          Set ChildtheFolder=fsoBrowse.GetFolder(onepath)
          Set ChildtheSubFolders=ChildtheFolder.SubFolders
     &nbs

上一个:格式提示文字
下一个:判断输入是否为中文的函数,共享给大家

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,