Signup · Login
Stardeveloper.com  
Home · Tutorials · Forums · Web Hosting Plans · Faisal Khan's Blog · Contact
Forums : ASP : ASP 3.0 : Listing Folders in Dropdown menu Signup · Login
Author Thread
Listing Folders in Dropdown menu
Posted in tutorial: Working with Drives, Folders and Files in ASP
·  Ibbi
User
Joined: 19 Apr 2003
Total Posts: 2
Listing Folders in Dropdown menu
Posted: 4 Nov 2003
Anybody knows how to list folders in dropdown menu. I wanna list all the main folders in one dropdwon menu. When user select a particular folder from the dropdown menu, in the second dropdown menu the sub folders of the main folder should automatically populate in the dropdown. Can anyone help me out in the problem.
·  Mogadon
User
Joined: 4 Feb 2004
Total Posts: 2
ASP Code to put files in directory into select/option form object
Posted: 4 Feb 2004
Sorry about the format - i'm limited to 4000 chars and this function is actually larger than that - but it'll give you the concept.
------------ code until end of post --------------
<!--#include virtual="/new/common/utils/qsort.asp" -->
<%
'
' DirFilestoOptions(DirName, SortOrder)
' DirName = name of relative path from curent file to generate options from
' SortOrder = True (ascending), False (descending)
'
' This subroutine takes a relative path spec., gets a list of files from it, sorts the
' list of files, and then outputs options as part of a <select> tag in a form.
' The option value=<x> will be set to point to the relative URL for the files.
' All date related names will be translated to Month and Year for display purposes
' if filelimit is specified, the files will be limited
'
sub DirFilestoOptions(DirName, FileLimit, LimitCompare, SortOrder)

dim FileSysObj, DirObj, fname, flink, tmp, fpath, fileobj, pos, npos, skipfile, iStart, iEnd, iStep

set FileSysObj=Server.CreateObject("Scripting.FileSystemObject")
fpath=server.MapPath(DirName)
set DirObj = FileSysObj.GetFolder(fpath)
if (isempty(DirObj)) then
response.write("<option value=""#"">Internal File Structure Error</option>")
else
dim I
I = DirObj.files.count
dim filelist()
redim filelist(I)
I=1
for each fileobj in DirObj.files
filelist(I) = fileobj.name
I=I+1
next
%> <script language="VB">
QSort(filelist, 1, DirObj.files.count)
</script>
<%
if SortOrder then
iStart = 1
iEnd = DirObj.files.count
iStep = 1
else
istart = DirObj.files.count
iend = 1
iStep = -1
end if
for I = iStart to iEnd step iStep
fname=lcase(filelist(I))
flink= DirName & "/" & fname
response.write("<option value=""" & flink & """>" & fname & "</option>")
next
end if
end sub
%>

Users Who Have Visited This Thread In Last 24 Hours
4 Visitors

Login
UserName Or Email Address:       Password:       Auto-Login:    
· Create New User Account
· Send Forgotten Password by Email
 
© 1999 - 2009 Stardeveloper.com, All Rights Reserved.