如何将所有子文件夹输出到 HTA 中的下拉列表? [英] How to output all sub-folder to a drop down list in a HTA?

查看:30
本文介绍了如何将所有子文件夹输出到 HTA 中的下拉列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个如下所示的代码.我想将 K:\work 中的所有子文件夹输出到此 HTA 中的下拉列表.因为 k:\work 中的所有子文件夹一直在变化.所以每次我点击下拉列表时,它需要有最新的内容.根据我的代码可以做到这一点吗?而且当我选择新客户时,我需要有一个弹出窗口,允许我输入名称并创建一个新文件夹.

I have a code like below. I want to output all sub-folder in K:\work to the drop down list in this HTA. Because all sub-folder in k:\work change all the time. so every time i click drop down list, it need to have the latest contents. is that possible to do this based on my code? and also when I select new customer, I need to have a popup window allowing me to enter the name and create a new folder.

在我的代码中,我只有 1 个下拉列表.我需要在这个 HTA 中有 7 个下拉列表,所有这些都具有相同的概念,如果不存在可以创建新文件夹.文件结构是这样的:K:\客户\设计\细节\订单......每个下拉列表将输出一级子文件夹,如果我从下拉列表中的上一级选择一个文件夹,下拉列表的其余部分将自动更改为该父文件夹中的子文件夹.任何人都可以帮助我吗?

In my code i only have 1 drop down list. I need to have 7 drop down lists in this HTA, all with same concept that can create new folder if doesn't exist. The file structure like this: K:\CUSTOMER\DESIGN\DETAIL\ORDER...... Each drop down list will output one level of sub-folder, if I select a folder from upper level in the drop down list, the rest of drop down list will be auto-changed to the sub-folder in that parent folder. Can any1 help me?

<HEAD>
<TITLE>K Drive Program Structure</TITLE>
<HTA:APPLICATION ID="AIDS" 
APPLICATIONNAME="K Drive Program Structure" 
BORDER="Dialog"
CAPTION="Yes"
SCROLL="NO"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SYSMENU="Yes"
WINDOWSTATE="maximize">
</HEAD>
<BODY>
<SCRIPT LANGUAGE="VBScript">

Sub Window_OnLoad
Window.Site.Focus
End Sub

Sub btn01_OnClick
Dim strProduct

oElements = Window.Site.SelectedIndex
strProduct = Window.Site.Options(oElements).Text

Select Case strProduct
    Case "AMCAN HONSEL"
        MsgBox "You selected AMCAN HONSEL",64,"Selection"
    Case "CHRYSLER ETOBICOKE"
        MsgBox "You selected CHRYSLER ETOBICOKE",64,"Selection"
    Case "CHRYSLER KOKOMO"
        MsgBox "You selected CHRYSLER KOKOMO",64,"Selection"
    Case "GM POWERTRAIN"
        MsgBox "You selected GM POWERTRAIN",64,"Selection"
    Case "MERCEDES BENZ"
        MsgBox "You selected MERCEDES BENZ",64,"Selection"
    Case "NEMAK"
        MsgBox "You selected NEMAK",64,"Selection"
    Case "NEW CUSTOMER"
        MsgBox "You selected NEW CUSTOMER",64,"Selection"
End Select

End Sub

Sub btn02_OnClick
Window.Close
End Sub
</SCRIPT>

<H2>K Drive Structure</H2>
<P>Please select or create: 
<SELECT NAME="Site">
<OPTION>AMCAN HONSEL</OPTION>
<OPTION>CHRYSLER ETOBICOKE</OPTION>
<OPTION>CHRYSLER KOKOMO</OPTION>
<OPTION>GM POWERTRAIN</OPTION>
<OPTION>MERCEDES BENZ</OPTION>
<OPTION>NEMAK</OPTION>
<OPTION>NEW CUSTOMER</OPTION>
</SELECT><P>

<BR>
<BR>
<Input Type = "Button" Name = "btn01" VALUE = "SUBMIT">
<Input Type = "Button" Name = "btn02" VALUE = "CLOSE">
<BR>
<BR>

</BODY>

推荐答案

您可以像这样在 HTA 中填充下拉列表:

You can fill a dropdown list in an HTA like this:

Sub UpdateList
  For Each opt In list.Options
    opt.RemoveNode
  Next

  Set fso = CreateObject("Scripting.FileSystemObject")
  For Each f In fso.GetFolder("K:\work").SubFolders
    Set opt = document.createElement("OPTION")
    opt.Text  = f.Name
    opt.Value = f.Path
    list.Add(opt)
  Next
End Sub

下拉列表的 HTML 标记应如下所示:

The HTML tag for the dropdown list should look like this:

<select id="list" name="list" onMouseOver="UpdateList"></select>

然而,构建一个带有下拉列表的目录浏览器并没有让我觉得这是一个热门的想法.您不能使用 Shell.BrowseForFolder<的任何特殊原因/a> 方法?

However, building a directory browser with dropdown lists doesn't strike me as such a hot idea. Any particular reason why you can't use the Shell.BrowseForFolder method?

Set os = CreateObject("Shell.Application")

basedir = os.Namespace("K:\work").Self.Path
Set fldr = os.BrowseForFolder(0, "Select folder:", &h10&, basedir)

您要解决的实际问题是什么?

What is the actual problem you're trying to solve?

这篇关于如何将所有子文件夹输出到 HTA 中的下拉列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆