helloise Posted January 6, 2011 Share Posted January 6, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/223559-get-id-from-selected-item-in-dropdown-list/ Share on other sites More sharing options...
trq Posted January 6, 2011 Share Posted January 6, 2011 You would need to place the id in the <option> elements value attribute or somewhere. Something like.... <option value="<?php echo $row->getId(); ?>"><?php echo $row->getName();?></option> Quote Link to comment https://forums.phpfreaks.com/topic/223559-get-id-from-selected-item-in-dropdown-list/#findComment-1155613 Share on other sites More sharing options...
helloise Posted January 6, 2011 Author Share Posted January 6, 2011 thank you i had it like that but i have to somehow pass that id to the next form when i hit the submit button cos i'll be needing it on the next form Quote Link to comment https://forums.phpfreaks.com/topic/223559-get-id-from-selected-item-in-dropdown-list/#findComment-1155617 Share on other sites More sharing options...
trq Posted January 6, 2011 Share Posted January 6, 2011 Cool, all sorted then. Quote Link to comment https://forums.phpfreaks.com/topic/223559-get-id-from-selected-item-in-dropdown-list/#findComment-1155619 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.