TheFilmGod Posted September 1, 2007 Share Posted September 1, 2007 how do I use php to grab the selected option from a selection form. <select name=\"notes\"> <option selected=\"selected\">Microsoft Word Document <option>Rich Text Format <option>Simple Text Format <option>HTML <option>Other/Special File </select> Code was in a php echo statement. Thus all double quotes were escaped. The NAME = "notes" What do I need to call within php to get the selected option? Last thing radio group. How do I get the selected option. This is what I got: <div id="radioleft"><input name="action[0]" type="radio" value="new" /> New Document</div> <div id="radioright"><input name="action[1]" type="radio" value="update" /> Update a Present Document</div> To get it with php: // If new document selected.. if ( isset($action[0]) { $form = "new"; } // If update document selected.. if ( isset($action[1]) { $form = "update"; } I want $form to give me New or update, depending on selection. Am I on a good start with the php script? I think I got the radio selections correct, but what about the select? Quote Link to comment https://forums.phpfreaks.com/topic/67528-solved-php-and-selections-and-radio/ Share on other sites More sharing options...
TheFilmGod Posted September 1, 2007 Author Share Posted September 1, 2007 I got the stuff to work. I was right along - for once! Now I have a BIGGER problem: <div id="radioleft"><input name="action[0]" type="radio" value="new" /> New Document</div> <div id="radioright"><input name="action[1]" type="radio" value="update" /> Update a Present Document</div> Since the names are different, the browser allows the user to select both of them! That is a no no! How can I make it so this doesn't happen, but I can call them in my php. - I simply want to do this: // Set variables to check submission $action[0] = $_POST['action'][0]; $action[1] = $_POST['action'][1]; how do I do this!!? help!! I'm a noob. Quote Link to comment https://forums.phpfreaks.com/topic/67528-solved-php-and-selections-and-radio/#findComment-339109 Share on other sites More sharing options...
Jessica Posted September 1, 2007 Share Posted September 1, 2007 Use the same name, just action. Then you don't have to check each one with POST, you just do $action = $_POST['action'] and it will show you the value. Quote Link to comment https://forums.phpfreaks.com/topic/67528-solved-php-and-selections-and-radio/#findComment-339111 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.