Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 8 of 8
  1. #1
    Senior Member
    Join Date
    Apr 2003
    Location
    Las Vegas
    Posts
    231
    Member #
    1169
    I want to display the files in a certain folder ex. images, into a dropdown menu for selection. So if I had files 1.jpg, 2.jpg, 3.jpg, then I want them to be selections for my dropdown menu. But I dont want to have to manualy put them in there. Makes sense right? Can this be done, and how would I do it? Thanks for the help

  2.  

  3. #2
    Senior Member splufdaddy's Avatar
    Join Date
    Feb 2003
    Location
    Boston, MA
    Posts
    4,488
    Member #
    735
    It can't be done with just HTML. Do you have access to PHP?

  4. #3
    Senior Member
    Join Date
    Dec 2003
    Posts
    1,274
    Member #
    4362
    This can't be done without a server-side language, like PHP.
    This would be the HTML and PHP for the <select>:
    PHP Code:
    <select name="menu1">
        <?php 
    $dir 
    "/absolute/path/to/the/folder/"

    // Open a known directory, and proceed to read its contents 
    if (is_dir($dir)) { 
       if (
    $dh opendir($dir)) { 
           while ((
    $file readdir($dh)) !== false) { 
               print 
    "<option value=\"{$file}\">{$file}</option>"
           } 
           
    closedir($dh); 
       } 

    ?>
      </select>

  5. #4
    Senior Member
    Join Date
    Apr 2003
    Location
    Las Vegas
    Posts
    231
    Member #
    1169
    Well the form is part of a CGI/Perl page, so no I dont think I can do PHP

  6. #5
    Senior Member
    Join Date
    Dec 2003
    Posts
    1,274
    Member #
    4362
    I bet that 99.9% of Perl capable host's are PHP capable too.

  7. #6
    Senior Member
    Join Date
    Apr 2003
    Location
    Las Vegas
    Posts
    231
    Member #
    1169
    Ok I think ill give it a shot, thanks

  8. #7
    Senior Member
    Join Date
    Apr 2003
    Location
    Las Vegas
    Posts
    231
    Member #
    1169
    For anyone that cares, I asked the same question on a different forum and it is possible to do this with CGI. Here is the response I got

    "You can use this script:

    Code:
    #!/usr/bin/perl 
    
    $basedir = "/home/sampleaddress/directory/"; 
    
    @files = ('*.php','*.html','*.htm'); 
    
    chdir($basedir); 
    foreach $file (@files) 
    { 
       $ls = `ls $file`; 
       @ls = split(/\s+/,$ls); 
       foreach $temp_file (@ls) 
       { 
          if (-d $file) 
          { 
             $filename = "$file$temp_file"; 
             if (-T $filename) 
             { 
                push(@FILES,$filename); 
             } 
          } 
          elsif (-T $temp_file) 
          { 
             push(@FILES,$temp_file); 
          } 
       } 
    } 
    
    print "Content-type: text/html\n\n"; 
    print "<FORM>\n"; 
    print "<SELECT>\n"; 
    foreach $FILE (@FILES) 
    { 
       print " <OPTION>$FILE\n"; 
    } 
    print "</SELECT>\n"; 
    print "</FORM>\n"; 
    
    exit;
    At this line you put the directory where the script should search for files:

    $basedir = "/home/sampleaddress/directory/";


    At this line you add the file types you would like to list. You can add more file types or just use one if you like:

    @files = ('*.php','*.html','*.htm');


    In your case (if you only want to list .jpg files) the line should look like this:

    @files = ('*.jpg');


    You can view a demo of this simple script at http://www.sampleaddress.com/cgi-bin/dir.pl "


    Hopefully this will be helpfull to anyone who may want to do this

  9. #8
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,657
    Member #
    1234
    Liked
    138 times
    sweet!
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Search tags for this page

drop down menu in a drin html
,
dropdown directory html
,
dropdown folder html
,
excel dropdown list showing folder contents
,
how to display a folder in a folder in drop down menu
,
how to display all images from a folder in html dropdown box
,
how to list files in a folder to drop-down
,
html dropdown menu with folder contents
,

html select dropdown list files in directory

,

php script for showing directory on option menu

Click on a term to search for related topics.
All times are GMT -6. The time now is 01:45 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com