Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-07-2012, 11:04 PM   PM User | #1
arjuns
New to the CF scene

 
Join Date: Aug 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
arjuns is an unknown quantity at this point
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 ?
arjuns is offline   Reply With Quote
Old 09-08-2012, 12:09 AM   PM User | #2
DrDOS
Senior Coder

 
Join Date: Sep 2010
Posts: 1,229
Thanks: 11
Thanked 156 Times in 156 Posts
DrDOS is infamous around these parts
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.
DrDOS is online now   Reply With Quote
Old 09-08-2012, 12:16 AM   PM User | #3
Logic Ali
Regular Coder

 
Logic Ali's Avatar
 
Join Date: Sep 2010
Location: London
Posts: 976
Thanks: 0
Thanked 203 Times in 198 Posts
Logic Ali will become famous soon enoughLogic Ali will become famous soon enough
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?
Logic Ali is online now   Reply With Quote
Old 09-08-2012, 12:33 AM   PM User | #4
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,498
Thanks: 18
Thanked 361 Times in 360 Posts
sunfighter is on a distinguished road
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.
sunfighter is offline   Reply With Quote
Old 09-08-2012, 04:27 AM   PM User | #5
jmrker
Senior Coder

 
jmrker's Avatar
 
Join Date: Aug 2006
Location: FL
Posts: 2,797
Thanks: 30
Thanked 462 Times in 456 Posts
jmrker will become famous soon enough
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.
jmrker is offline   Reply With Quote
Old 09-08-2012, 02:18 PM   PM User | #6
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,498
Thanks: 18
Thanked 361 Times in 360 Posts
sunfighter is on a distinguished road
@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.
sunfighter is offline   Reply With Quote
Reply

Bookmarks

Tags
dropdown, html, javascript, populate, select

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:58 PM.


Advertisement
Log in to turn off these ads.