Friday, 16 August 2013

PHP code to get selected text of a combo box

PHP code to get selected text of a combo box

I have a combo box named "Make". In that combo box I'm loading vehicle
manufacturer names. when i click SEARCH button i want to display the
selected manufacturer name. Below is part of my html code.
<label for="Manufacturer"> Manufacturer : </label>
<select id="cmbMake" name="Make" >
<option value="0">Select Manufacturer</option>
<option value="1">--Any--</option>
<option value="2">Toyota</option>
<option value="3">Nissan</option>
</select>
<input type="submit" name="search" value="Search"/>
Below is my PHP code so far i've done.
<?php
if(isset($_POST['search']))
{
$maker = mysql_real_escape_string($_POST['Make']);
echo $maker;
}
?>
If i select Toyota from the combo box and press SEARCH button, i'm getting
the answer as '2' . It means it gives me the value of the 'Toyota'. But i
want to display the name 'Toyota'. How can i do that. ?? Please help me
....

No comments:

Post a Comment