ASP VBScript + Javascript 以字符串方式二级联显示文件夹
作用: 列出当前设置目录中的子文件夹, 再列出子文件夹的下级文件夹, 当改变一级子文件夹的时候, 动态显示隶属于其的子文件夹.
注: Javascript 以字符串方法判断级联对象, 也就是一级子文件夹的名字.
//并且在页面加载的时候以一级子文件夹选择的目标关联显示二级列表框中的内容.
shawl.qiu
2006-7-28
linenum
<%@LANGUAGE="VBSCRIPT"%>
<% option explicit
dim path:path="include/system/themes/"
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' 列出某文件夹中的一级子文件夹, 并加上 <option></option>
' call sGetSubfolderNameAtchOpt("include/managemain/language",sitefgstyle)
private sub sGetSubfolderNameAtchOpt(byref Path,check)
dim fso, gFolder, folder, i, fldNm
set fso=server.CreateObject("scripting.fileSystemObject")
set gFolder=fso.getFolder(server.MapPath(path))
for each folder in gFolder.subfolders
fldNm=folder.name
if check=folder.name then response.write "<option selected=""selected"" value="""&_
fldNm& """>" else response.write "<option value="""&fldNm&""">"
response.write fldNm
response.write "</option>"
next
set gFolder=nothing
set fso=nothing
end sub %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<script>
var subcat;subcat = new Array(); //定义显示子类数组
<% dim fso, gFolder, varCnt, spFld, sbFld
set fso=server.CreateObject("scripting.fileSystemObject")
set gFolder=fso.getFolder(server.MapPath(path))
varCnt=0
for each spFld in gFolder.subfolders
for each sbFld in spFld.subfolders%>
subcat[<%response.write varCnt%>] = new Array("<%response.write trim(sbFld.name)%>","<%response.write trim(spFld.name)%>");
<% varCnt=varCnt+1
next
next
set gFolder=nothing
set fso=nothing %>
varCnt=<%response.write varCnt%>
function fChangeLoct(pathValue) {
document.all.sbFld.length = 0;
var pathValue=pathValue,i
for (i=0;i < varCnt; i++) {
if (subcat[i][1] == pathValue) {
document.all.sbFld.options[document.all.sbFld.length] = new Option(subcat[i][0], subcat[i][0]);
}
}
}
</script>
<body onload="fChangeLoct(document.all.spFld.options[0].value)" >
<form action="" method="post" name="formT" id="formT">
<select name="spFld" onchange="fChangeLoct(options[selectedIndex].value)">
<% call sGetSubfolderNameAtchOpt(path,"schinese") %>
</select><br />
<select name="sbFld"></select>
</form>
</body>
</html>