Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Retrieve folder contents to populate drop down list

LEGEND ,
Feb 19, 2008 Feb 19, 2008

Copy link to clipboard

Copied

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!


TOPICS
Server side applications

Views

314
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Feb 19, 2008 Feb 19, 2008

Copy link to clipboard

Copied

Try adding this to your code Notice the extra if statement that is added in the middle

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 20, 2008 Feb 20, 2008

Copy link to clipboard

Copied

LATEST
Hi Mike,

Much obliged for the help! At first I couldn't get the code to work, but
then I realised there was an extra '=' just after your initial IF. I removed
it and it works fine now! Yay!

"MikeL7" <webforumsuser@macromedia.com> wrote in message
news:fpge86$bu0$1@forums.macromedia.com...
> Try adding this to your code Notice the extra if statement that is added
> in the
> middle
>
> <%
> dim jm_fso, jm_file, jm_types, jm_path, jm_folder,jm_show,jm_i,jm_ext
> jm_ext=true
> jm_path = "images/"
> 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 & """"
>
> If =(Company.Fields.Item("Logo").Value)= jm_File.Name THEN
> response.write " selected=""selected"""
> End If
>
> response.write ">" & jm_File.Name & "</option>" &vbcrlf
> else
> response.write "<option value=""" & jm_File.Name & """>" &
> mid(jm_File.Name,1,len(jm_File.Name)-4) & "</option>"
> end if
> end if
> next
> set jm_file=nothing
> set jm_folder = nothing
> set jm_fso=nothing
> %>
> </select>
>


Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines