Question
Retrieve folder contents to populate drop down list
Hi,
I am using the following code to list the contents of a specific folder on
my server in a drop down menu. This works perfectly. However, I want the
default value that is selected upon loading the page to be equal to a value
in a recordset :
<%=(Company.Fields.Item("Logo").Value)%>
Can anyone show me how to modify the code to make the default the above
value?
<select name="logo" id="logo" style="width:175px;">
<option value="blank.gif" ></option>
<%
dim jm_fso, jm_file, jm_types, jm_path, jm_folder,jm_show,jm_i,jm_ext
jm_ext=true
jm_path = "../media/" & (Company.Fields.Item("CompanyID").Value) & "/logos/"
jm_types = split(replace("asp,html, jpg, gif"," ",""),",")
Set jm_fso = Server.CreateObject("Scripting.FileSystemObject")
Set jm_folder = jm_fso.GetFolder(Server.MapPath(jm_path))
For Each jm_file in jm_folder.Files
jm_show=false
for jm_i=0 to ubound(jm_types,1)
If lcase(right(jm_file.name,3)) = jm_types(jm_i) then jm_show=true
next
If jm_show=true then
if jm_ext=true then
response.write "<option value=""" & jm_File.Name & """>" & jm_File.Name &
"</option>" &vbcrlf
else
response.write "<option value=""" & jm_File.Name & """>" &
mid(jm_File.Name,1,len(jm_File.Name)-4) & "</option>" &vbcrlf
end if
end if
next
set jm_file=nothing
set jm_folder = nothing
set jm_fso=nothing%>
</select>
I'm working on DW8, Windows, ASP VBScript
Thanks!
I am using the following code to list the contents of a specific folder on
my server in a drop down menu. This works perfectly. However, I want the
default value that is selected upon loading the page to be equal to a value
in a recordset :
<%=(Company.Fields.Item("Logo").Value)%>
Can anyone show me how to modify the code to make the default the above
value?
<select name="logo" id="logo" style="width:175px;">
<option value="blank.gif" ></option>
<%
dim jm_fso, jm_file, jm_types, jm_path, jm_folder,jm_show,jm_i,jm_ext
jm_ext=true
jm_path = "../media/" & (Company.Fields.Item("CompanyID").Value) & "/logos/"
jm_types = split(replace("asp,html, jpg, gif"," ",""),",")
Set jm_fso = Server.CreateObject("Scripting.FileSystemObject")
Set jm_folder = jm_fso.GetFolder(Server.MapPath(jm_path))
For Each jm_file in jm_folder.Files
jm_show=false
for jm_i=0 to ubound(jm_types,1)
If lcase(right(jm_file.name,3)) = jm_types(jm_i) then jm_show=true
next
If jm_show=true then
if jm_ext=true then
response.write "<option value=""" & jm_File.Name & """>" & jm_File.Name &
"</option>" &vbcrlf
else
response.write "<option value=""" & jm_File.Name & """>" &
mid(jm_File.Name,1,len(jm_File.Name)-4) & "</option>" &vbcrlf
end if
end if
next
set jm_file=nothing
set jm_folder = nothing
set jm_fso=nothing%>
</select>
I'm working on DW8, Windows, ASP VBScript
Thanks!
