using file system object to view directory (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


Rizzo -> using file system object to view directory (12/8/2001 9:29:15)

I found a nifty script that uses the file system object and lets you see the files in a directory which is a good start for what I need. It was setup by default as showing the file names as text but I want the file names to be options that can be selected so in front page I added the drop down menu to it now it looks like this:

<%
Set MyDirectory=Server.CreateObject("Scripting.FileSystemObject")
Set MyFiles=MyDirectory.GetFolder(Server.MapPath("/teamhs/images"))
For each filefound in MyFiles.files
%>

<select name="choose">
<option><% =filefound.Name %></option>
</select>

<%
Next
%>

only problem is, each file creates its own drop down menu...that's not what I wanted to do :) look http://www.graphic-group.com/teamhs/dir.asp
there should be 2 files in one drop down menu instead of 2 drop down menu's with one file each, anyone have a clue?





martinchisholm -> RE: using file system object to view directory (12/8/2001 12:07:04)

Hi, I think your code is correct, just slightly in the wrong order.

You are looping the creation of the option box as well as the content. I think by simply moving the option box make up outside of the loop will solve your problem, try the below:

<%
Set MyDirectory=Server.CreateObject("Scripting.FileSystemObject")
Set MyFiles=MyDirectory.GetFolder(Server.MapPath("/teamhs/images"))
%>
<select name="choose">
<%
For each filefound in MyFiles.files
%>

<option><% =filefound.Name %></option>

<%
Next
%>

</select>





Rizzo -> RE: using file system object to view directory (12/8/2001 12:34:20)

Hey you saved my day, thanks man it works great thanks again!





Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.046875