tmyonline Posted March 9, 2009 Share Posted March 9, 2009 Hi guys, This question is probably easy for most of you! I have a PHP related question since I'm using it. I have a html form like this: <select name="fqdn" multiple="multiple"> <option value="A">A</option> <option value="B">B</option> <option value="C">C</option> <option value="D">D</option> <option value="E">E</option> ... </select> This form will allow multiple selections. Now, if it were a single selection, then I could say if (isset($_POST['fqdn'])) { echo 'fqdn selected is: ' . $_POST['fqdn']; } to find out which option has been selected. But now, suppose my users select options B, C, and E and clicks the submit button, how do I find out which options have been selected ? The problem here is that each <option> tag does not have its own "name" attribute, so it's like there is one name that has multiple values. I appreciate your help. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/148611-using-php-to-get-html-multiple-selects/ Share on other sites More sharing options...
JonnoTheDev Posted March 9, 2009 Share Posted March 9, 2009 Set as an array <select name="fqdn[]" multiple="multiple"> Then foreach($_POST['fqdn'] as $fqdn) { } Quote Link to comment https://forums.phpfreaks.com/topic/148611-using-php-to-get-html-multiple-selects/#findComment-780420 Share on other sites More sharing options...
tmyonline Posted March 9, 2009 Author Share Posted March 9, 2009 Hi Neil, You are the man. It worked great. Thanks so much! Quote Link to comment https://forums.phpfreaks.com/topic/148611-using-php-to-get-html-multiple-selects/#findComment-780445 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.