Jr0x Posted December 30, 2006 Share Posted December 30, 2006 Hi, i'm a beginner php programmer. I have something to ask regarding retrieving information from drop down menu.Let's say i have a drop down menu in page1.php and i want to get/display the information on page2.php.Dummy set of drop down list:[code] <select name="select"> <option value="a">Apple</option> <option value="o">Orange</option> <option value="b">Banana</option> </select>[/code]i tried using the same method as retrieving radiobutton. But it doesn't works.Dummy code:[code=php:0]<?php$fruit = $_POST['select'];echo $fruit;?>[/code]This is different from normal radio button where you just need to get the nameof the buttons. As all the name of the button are the same.However, for drop down list, there is only 1 name in this case "select". But with different values.Can i do something like,[code=php:0]<?phpif ($_POST['select'] && value = "a") echo "Apple";elseif ($_POST['select'] && value = "o") echo "Orange";elseif ($_POST['select'] && value = "b") echo "Banana";?>[/code]Thanks for the help, because i tried a few method and couldn't work so have no choice but to seek for help.Regards,Jr0x Link to comment https://forums.phpfreaks.com/topic/32298-how-to-retrieve-information-from-drop-down-menu/ Share on other sites More sharing options...
dbo Posted December 30, 2006 Share Posted December 30, 2006 $blah = $_POST['select'];That should yield the selected value of your drop down. (a, o, or b);How you process that on the backend is up to you. if( $blah == 'a' ) { echo "Apple"; }or you might consider:<select name="fruit"> <option value="Apple">Apple</option> <option value="Orange">Orange</option> <option value="Banana">Banana</option></select>Then you could just sayecho $_POST['fruit']; Link to comment https://forums.phpfreaks.com/topic/32298-how-to-retrieve-information-from-drop-down-menu/#findComment-150089 Share on other sites More sharing options...
Jr0x Posted December 31, 2006 Author Share Posted December 31, 2006 Okay. Got it.Thank You.Regards,Jr0x Link to comment https://forums.phpfreaks.com/topic/32298-how-to-retrieve-information-from-drop-down-menu/#findComment-150291 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.