Forum Moderators: open

Message Too Old, No Replies

FileSystemObject Problems!

Scripting help required please

         

JulesMG

4:02 pm on May 17, 2006 (gmt 0)

10+ Year Member



am trying to use FileSystemObject to populate a drop down menu on my addProducts.asp and editProducts.asp pages with a list of product image names from a folder containing available product images.

I used the following code to try to create my drop down but I get an 'Object Required' error displayed instead of the list of files in my admin/uploads folder. Please can you give me some pointers as to why this is happening. I'm new to this stuff and it's driving me crazy

I am using

<%
Set objFSO=Server.CreateObject("Scripting.FileSystemObject")
Set objFold=objFSO.GetFolder("E:\admin\uploads")
Set objFiles=objFold.Files
%>

and then generating my drop down using

<select name="productThumb" id="productThumb">
<option><%For Each objFile in objFolder.Files
objFile.Name
Next
%></option>
</select>

Thank you in anticipation

Jules

JulesMG

5:46 pm on May 17, 2006 (gmt 0)

10+ Year Member



Hi, I now have the list of images in my drop dowm menu. Thanks for all your help. But the image names are listed in one long string.

Please, how do I change the following so that each name appears on its own line in the drop down and not as one long string! Thanks

<select name="productThumb" id="productThumb">
<option selected>
<%
For Each objFile in objFold.Files
Response.Write objFile.Name & "<br>"
Next
%>

flyerguy

7:29 am on May 18, 2006 (gmt 0)

10+ Year Member



A <br> break will not work in the context of a dropdown box, what you need to do is format each database record as an <Option>, ala:

<select name="productThumb" id="productThumb">
<option selected>
<%
For Each objFile in objFold.Files
Response.Write "<option value=""" & objFile.Name & """>" & objFile.Name & "</option>"
Next
%>