View Single Post
  #1 (permalink)  
Old 03-04-2007, 08:05 PM
aventvoy's Avatar
aventvoy aventvoy is offline
WebProWorld Member
 
Join Date: Jul 2003
Location: Vancouver
Posts: 48
aventvoy RepRank 0
Default PHP form and use of <select ...> menu option

Hello,
Here comes today's newbie question... Some will laugh and see this sooooo easy... But I'm stuck...
I am working on a form (page1.php) with username and password, no problem so far...
On this same page (and once username and password are validated, so far I managed), the user must be able to select a file from a file list, in a menu like this:
<select name="file">

<option value="empty">Select a file</option>
<option value="file1">File 1</option>
<option value="file2">File 2</option>
etc...
The files are stored in a folder (./folder).
But in this folder I have many files, .txt or .jpg, and I only want to display the .txt files.
I can do all this in html, no problem, and display the file on a page2.php, but it means I have to manually type as many <option value="etc"...> as there are files in this folder. And there are many!

I assume there must be a way to retrieve all the .txt files and display them in a drop down/select menu for selection, yes?
How can I do that? I read something about traversing a directory (rewind() and dir()) but I don't know how to use these functions and diplay the files in a select menu...
Could anyone help me?
Thanks for your patience with newbies!
A.
__________________
http://www.aventurevoyages.com
Reply With Quote