Click to See Complete Forum and Search --> : get image filename and populate a javascript list


jrthor2
04-26-2005, 01:18 PM
I have an html editor that I want to display a dropdown list of imges in a particular directory, but the javascript code has to look like this:

var ImageList = new Array(
// Name, URL
["Logo 1", "logo.jpg"],
["Logo 2 Over", "logo_over.jpg"]
);

I want the array to be a dynamic listing of images from a directory i specify. How can I do this?

Thanks!

phpnovice
04-26-2005, 07:12 PM
This is some code I have to display a directory listing of a folder in a table. You can modify this to build a JavaScript data array instead:

<%
'
' ----- File Directory Handler -----
'
Dim objFSO, objFolder, objFile, strPath
strPath = Server.MapPath("/downloads/")
'
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strPath)
'
For Each objFile in objFolder.Files
%>
<tr>
<td align="left" class="cell"><a href="file_master.asp?name=<% = objFile.Name %>&path=/downloads/&type=<% = GetMimeType(objFile.Name) %>"><% = objFile.Name %></a>&nbsp;</td>
<td align="right" class="cell"><% = objFile.Size %>&nbsp;</td>
<td align="left" class="cell"><% = objFile.Type %>&nbsp;</td>
<td align="right" class="cell"><% = objFile.DateCreated %>&nbsp;</td>
<td align="right" class="cell"><% = objFile.DateLastModified %>&nbsp;</td>
<td align="left" class="fixed"><% = GetFileAttributes(objFile.Attributes) %>&nbsp;</td>
</tr>
<%
Next
'
Set objFile = Nothing
Set objFolder = Nothing
Set objFSO = Nothing
'
' ----- End of File Directory Handler -----
'
%>