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.CreateObj开发者_运维问答ect("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:
- Have the JavaScript post the form whenever the static dropdown changes. When this post occurs, you can pull the folders for the dynamic dropdown.
- 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).
精彩评论