maxrpg123 Posted January 17, 2010 Share Posted January 17, 2010 hello I have this code which works perfectly for what i want and what it does is gets every file in a folder and lists them all into a List/Menu box on the page. <?php echo "<select name='yourfiles'>"; //The path to the style directory $dirpath = "New Folder/"; $dh = opendir($dirpath); while (false !== ($file = readdir($dh))) { //Don't list subdirectories if (!is_dir("$dirpath/$file")) { //Truncate the file extension and capitalize the first letter echo "<option value='$file'>" . htmlspecialchars(ucfirst(preg_replace('/\.txt*$/', '', $file))) . '</option>'; } } closedir($dh); //Close Select echo "</select>"; ?> What i cant figure out is how do i add a submit button to it and display the selected file name on the next page? What im aiming to do is select a file from the list menu and when i click submit it will open the selected file and show its contents (text) on the webpage. any help would be greatly appreciated thank you Quote Link to comment https://forums.phpfreaks.com/topic/188817-all-files-into-listmenu-with-submit-button-help/ Share on other sites More sharing options...
wildteen88 Posted January 17, 2010 Share Posted January 17, 2010 You'll first need to wrap your code in <form></form> tags. Then after the closing select tag (</select>). You'll want to place your submit button. Quote Link to comment https://forums.phpfreaks.com/topic/188817-all-files-into-listmenu-with-submit-button-help/#findComment-996833 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.