简体   繁体   中英

dependent drop down list

I want to make two drop down lists. The first list has static data( folder structure), so I can use an array for it. Depending on the folder or option selected in the first list, the second list shows the sub-folders in it. but the sub-folders keeps on changing, so I have to use asp fso for it. I am using the following fso code:

<html>
<body>
    <%@ Language=VBScript  ENABLESESSIONSTATE = False%>  
    <form Name="sushant" method="post" action="sushant.asp">  
        <select id="selFiles" name="selFiles" class="Select" style="width: 250px" tabindex="130">  
        <% 
          Dim fso, folder, files  
          Set fso=Server.CreateObject("Scripting.FileSystemObject")    
          Set folder=fso.GetFolder("D:\")    
          Set files=folder.SubFolders      
          For each folderIdx In files   
              Response.Write("<option>" + folderIdx.Name + "</option>")  
          Next    
        %>
        </select>
    </form>
</body>  
</html> 

I don't know how to make such a dependent list. Any help is really appreciated.

You'll have to involve JavaScript. What you need to have happen is the static dropdown trigger some event whenever it changes, in order to update your dynamic dropdown. So you can:

  1. Have the JavaScript post the form whenever the static dropdown changes. When this post occurs, you can pull the folders for the dynamic dropdown.
  2. Have the JavaScript trigger an Ajax event whenever the static dropdown changes. I would recommend jQuery for this.

Since the folders change often, those are the only two options I'd recommend. If you need help with a specific implementation, there are lots of resources available (this is a very common feature that people use jQuery/Ajax for), and it should work with any server-side language (classic ASP or otherwise).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM