1.11M Members

retrieving drop-down-menu data

 
0
 

hey guys.

this may be very trivial, but i cant figure out a way...

i want to retrieve the data entered by the user through a drop-down-menu using POST method.

I am unable to do so...

kindly suggest

P.S. I am how to retrieve text-field data from a form, but not drop-menus....

thx...

 
0
 

Just like how you do it for text fields. $value = $_POST['dropdownboxname'];

 
0
 

Example:

<form action="process.php" method="post" enctype="multipart/form-data" name="form1" target="_self" id="form1">

<select name="ProductName">
            <option>Please, select</option>
            <option value="Cooling System">Cooling System</option>
            <option value="Desktop PC">Desktop PC</option>
            <option value="DVD Player">DVD Player</option>
            <option value="Laptop">Laptop</option>
            <option value="Media Player">Media Player</option>
            <option value="Monitor">Monitor</option></select>
</form>

Then, create a file called process.php to process the form.

 
0
 

You can get the value of a combo box using the statement
$value=$_POST;

for example
if you have a combo box like this
<table>
<tr>
<td>List</td>
<td><select name="combo" id="combo">
<option value="1">Anu</option>
<option value="2">Ajay</option>
<option value="3">Midhun</option>
</select></td>
</tr>
</table>

Now you can get the value of the selected item using the statement..

<?php
$value=$_POST;
echo "value= ".$value;
?>
If you select the name 'Ajay' in combo then it will display
value=2

If you want to get the name 'Ajay' as the value..then you have to give the name itself in the value field. for example
<table>
<tr>
<td>List</td>
<td><select name="combo" id="combo">
<option value="Anu" selected>Anu</option>
<option value="Ajay">Ajay</option>
<option value="Midhun">Midhun</option>
</select></td>
</tr>
</table>

<?php
$value=$_POST;
echo "value= ".$value;
?>
now If you select the name 'Ajay' in combo then it will display
value=Ajay

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article