ASP VBScript Javascript 以字符串方式二级联…

2008-02-23 09:13:15来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

ASP VBScript JavaScript 以字符串方式二级联显示文件夹

作用: 列出当前设置目录中的子文件夹, 再列出子文件夹的下级文件夹, 当改变一级子文件夹的时候, 动态显示隶属于其的子文件夹.

注: Javascript 以字符串方法判断级联对象, 也就是一级子文件夹的名字.
//并且在页面加载的时候以一级子文件夹选择的目标关联显示二级列表框中的内容.

shawl.qiu
2006-7-28

    linenum
  1. <%@LANGUAGE="VBScript"%>
  2. <% option explicit
  3. dim path:path="include/system/themes/"
  4. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  5. ' 列出某文件夹中的一级子文件夹, 并加上 <option></option>
  6. ' call sGetSubfolderNameAtchOpt("include/managemain/language",sitefgstyle)
  7. private sub sGetSubfolderNameAtchOpt(byref Path,check)
  8. dim fso, gFolder, folder, i, fldNm
  9. set fso=server.CreateObject("scripting.fileSystemObject")
  10. set gFolder=fso.getFolder(server.MapPath(path))
  11. for each folder in gFolder.subfolders
  12. fldNm=folder.name
  13. if check=folder.name then response.write "<option selected=""selected"" value="""&_
  14. fldNm& """>" else response.write "<option value="""&fldNm&""">"
  15. response.write fldNm
  16. response.write "</option>"
  17. next
  18. set gFolder=nothing
  19. set fso=nothing
  20. end sub %>
  21. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  22. <html XMLns=" http://www.w3.org/1999/xhtml">
  23. <head>
  24. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  25. <title>Untitled Document</title>
  26. </head>
  27. <script>
  28. var subcat;subcat = new Array(); //定义显示子类数组
  29. <% dim fso, gFolder, varCnt, spFld, sbFld
  30. set fso=server.CreateObject("scripting.fileSystemObject")
  31. set gFolder=fso.getFolder(server.MapPath(path))
  32. varCnt=0
  33. for each spFld in gFolder.subfolders
  34. for each sbFld in spFld.subfolders%>
  35. subcat[<%response.write varCnt%>] = new Array("<%response.write trim(sbFld.name)%>","<%response.write trim(spFld.name)%>");
  36. <% varCnt=varCnt 1
  37. next
  38. next
  39. set gFolder=nothing
  40. set fso=nothing %>
  41. varCnt=<%response.write varCnt%>
  42. function fChangeLoct(pathValue) {
  43. document.all.sbFld.length = 0;
  44. var pathValue=pathValue,i
  45. for (i=0;i < varCnt; i ) {
  46. if (subcat[i][1] == pathValue) {
  47. document.all.sbFld.options[document.all.sbFld.length] = new Option(subcat[i][0], subcat[i][0]);
  48. }
  49. }
  50. }
  51. </script>
  52. <body onload="fChangeLoct(document.all.spFld.options[0].value)" >
  53. <form action="" method="post" name="formT" id="formT">
  54. <select name="spFld" onchange="fChangeLoct(options[selectedIndex].value)">
  55. <% call sGetSubfolderNameAtchOpt(path,"schinese") %>
  56. </select><br />
  57. <select name="sbFld"></select>
  58. </form>
  59. </body>
  60. </html>

下一篇: 如何实现XML XSL javascript数据排序

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:如何使用Javascript XSLT 处理XML文件(2)

下一篇:Grails EJB Domain Models