How can I create a drop down list that after choosing one in the list and clicking submit, the accepting page should use switch statement to check the corresponding value of the option in the list...
for example, the code below is a switch statement, than when my input is Jehzeel1, the page shows jehzeel likes apples, and so on...
<?php
$X = input;
switch ($X) {
case "Jehzeel1":
echo "Jehzeel likes apples";
break;
case "Jehzeel2":
echo "Jehzeel likes bananas";
break;
case "Jehzeel3":
echo "Jehzeel likes oranges";
break;
default:
echo "Input did not match with any case";
}
?>
My main question is, how can I make a drop down list that its input will be used in the switch statement...
my options are
- Jehzeel1
- Jehzeel2
- Jehzeel3
if I select Jehzeel1, the page will then show, Jehzeel likes apples...
This is my drop down menu...
<form name="input">
<select name="dropdown">
<option value="Jehzeel1">Jehzeel1</option>
<option value="Jehzeel1">Jehzeel1</option>
<option value="Jehzeel1">Jehzeel1</option>
</select>
</form>
but it doesn't work, is there something wrong with my code? or something else that I forget to define..? will i change the form name? or is it ryt? nid help.. im a very newbie on this stuff 🙁