Populating list box and passing value
Posted: Tue Mar 02, 2004 11:59 am
I have a main web folder that has several sub directories in it. I want to populate a list box with these directories and when the user chooses a value out of the dropdown list it will pass that value to another page.
html...
The code from the test.php populates the dropdown list just fine but it won't pass the variable selected to done.php. I read that I need to give each option a key but wasn't sure if that was true for my situation or how to go about that.
Can anyone give me any pointers?
Thanks!
html...
Code: Select all
(test.php)
<form action="done.php" method="post">
<select name = input>
<?
$dir = "/web/directory/"; //sets directory path
// Open a known directory, and proceed to read its contents
if (is_dir($dir))
{
if ($dh = opendir($dir))
{
while (($file = readdir($dh)) !== false) //while files and folders are being read
{
if (filetype($dir . $file) == dir) //if the filetype is a directory and not a file
{
echo '<option>'.$file.'</option>';
}
}
closedir($dh);
}
}
?>
</select>
<input type="submit" value="Edit">
----------------------------------------------------------------
(done.php)
<html>
<form>
<input type="text" value="<?echo $_POSTї"input"]; ?>">
</form>
</html>Can anyone give me any pointers?
Thanks!