I am new to PHP and attempting get the value of an option chosen from a select tag. I am familiar with some types of input such as radio, text, checkboxes e.t.c. my question is
You need to give the name attribute to the select, not the options.
<form name="chosen_party" action="party.php" method="get">
<select name="party_type">
<option value="democrat">Democrat</option>
<option value="republican">Republican</option>
<option value="independent">Independent</option>
<option value="undecided">Undecided</option>
</select>
<input type="submit" value="Submit">
</form>
Then in php, you can access $_GET['party_type']
, which will be the option that was chosen.
First give a name to select tag. and in the case of option give a value to each option. like this..
<form name="chosen_party" action=party.php method="get">
<select name="party_type">
<option value="democrat">Democrat</option>
<option value="republican">Republican</option>
<option value="independent">Independent</option>
<option value="undecided">Undecided</option>
</select>
<input type=submit value="Submit">
</form>
Then in the php there is a little syntax problem. You have to put $party_select outside of the quote. The code should be..
<?php
$party_select = $_GET['party_type'];
echo 'User has chosen '.$party_select;
?>
Hope this helps..
option says that it is an option. Don't need the type attribute at all.
<select name="myOptionList">
<option value="1">First option</option>
<option value="2">Second option</option>
</select>
this is enough markup, more here http://www.w3schools.com/tags/tag_select.asp