I am a complete novice to php, scripting and html. I am trying to dynamically generate a dropdown box with a list of folders and then I want to generate a list links to the files for the selected folders. I have been searching for the solution which I am sure is really obvious but I don't full understand the code structure
I have this to generate the dropdown box and populate with the folders in the "Docs\" directory
I also have this to generate links from a set folder
What I don't understand is how to call the second set of code as a function based on the first set of code and have it display underneath the drop down box. I have tried with onchange but as I say, I must be missing something basic
I have this to generate the dropdown box and populate with the folders in the "Docs\" directory
Code:
<!DOCTYPE html>
<html>
<body>
<select id="mySelect" >
<?php
$dirs = glob("Docs\*", GLOB_ONLYDIR);
foreach($dirs as $val)
{
echo '<option value="'.$val.'">'.basename($val)."</option>\n";
}
?>
</select>
</body>
</html>
I also have this to generate links from a set folder
Code:
<!DOCTYPE html>
<html>
<body>
<?php
foreach (glob("Docs\PB02\*.pdf") as $pathtodocs)
{
$filename = basename($pathtodocs);
echo "<a href=\"$pathtodocs\">$filename</a>";
echo "<br>";
}
?>
</body>
</html>