Page 1 of 1

how to get id from selected item in dropdown list?

Posted: Thu Jan 06, 2011 5:22 am
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

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

Posted: Thu Jan 06, 2011 5:36 am
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'];