Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Aug 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Populating a drop down list with file names

    Hi,

    Is there a way to populate a drop down list with filenames in a particular folder ?

  • #2
    Senior Coder
    Join Date
    Sep 2010
    Posts
    2,002
    Thanks
    15
    Thanked 236 Times in 236 Posts
    Javascript won't read the contents of the folder. You will have to make up a javascript array with the file names as a .js file and have javascript reference it.

  • #3
    Senior Coder Logic Ali's Avatar
    Join Date
    Sep 2010
    Location
    London
    Posts
    1,028
    Thanks
    0
    Thanked 207 Times in 202 Posts
    Quote Originally Posted by arjuns View Post
    Hi,

    Is there a way to populate a drop down list with filenames in a particular folder ?
    Yes.

    Now would you like to ask a less abstract question, perhaps supplying some useful information like the form in which your list currently exists, and in what order the filenames are to be arranged?

  • #4
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,225
    Thanks
    23
    Thanked 606 Times in 605 Posts
    Yes. php can read file names from a folder and generate the drop down.

    Your manual of dir php stuff is located here http://www.php.net/manual/en/function.scandir.php use the menu on the left side to see all.

    Rest (drop downs) should self explanatory. php wins over js here.

  • #5
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,087
    Thanks
    38
    Thanked 498 Times in 492 Posts

    Lightbulb

    Quote Originally Posted by sunfighter View Post
    Yes. php can read file names from a folder and generate the drop down.

    Your manual of dir php stuff is located here http://www.php.net/manual/en/function.scandir.php use the menu on the left side to see all.

    Rest (drop downs) should self explanatory. php wins over js here.
    Basic assumption that may have been overlooked here...
    Not all users have access to execute php code.

    Task can be accomplished with JS if it remains enabled on your browser.

  • #6
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,225
    Thanks
    23
    Thanked 606 Times in 605 Posts
    @jmrker You are correct. Not all servers use php, but 77.9% of them do. IMHO that means its a good assumption. It was not too long ago when I'd be told that I should not recommend coding in javascript because "not all people have it turned on in their browsers" At that time 90% of the users did have it turned on.

    I also assumed that the folders could be on the server. I don't think js can read those by it's self. While php would read a file server side or user side. So I still think it's the better choice. Maybe I should have said server side language instead of php, but I only know php and can not say the other can do the job.


  •  

    Tags for this Thread

    Posting Permissions

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