how to get id from selected item in dropdown list?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
helloise
Forum Commoner
Posts: 31
Joined: Tue Sep 21, 2010 4:20 am

how to get id from selected item in dropdown list?

Post by helloise »

i have the following code:
<td width='100px'>Suppliers
<select name="supplier">
<?php
$catcher_id = $service->getCatcherId();
$supplier_names = LpmAdnetworkPeer::getByName($catcher_id);
foreach($supplier_names as $row)
{
?>
<option><?php echo $row->getName();
?></option>
<?php
}
?>
</select>
</td>

then on the same form i have a submit button that takes me to the next form..the problem now is how can i access the ID of the item seleted in the dropdown on the NEXT form please?
i can get the name from the list by $_POST['supplier'] on the next form
thanks
klevis miho
Forum Contributor
Posts: 413
Joined: Wed Oct 29, 2008 2:59 pm
Location: Albania
Contact:

Re: how to get id from selected item in dropdown list?

Post by klevis miho »

Make an input type hidden like this:
<input type="hidden" name="id" value="<?php echo $catcher_id; ?>" ?>

and get it on the other form like this:
$id = $_POST['id'];
Post Reply