disable some option in selectbox

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
Lphp
Forum Commoner
Posts: 74
Joined: Sun Jun 26, 2011 9:56 pm

disable some option in selectbox

Post by Lphp »

Hi all I have drop down select box the value is select out of db , is that possible to disable some option ?
if yes. how to handle it :|
User avatar
manohoo
Forum Contributor
Posts: 201
Joined: Wed Dec 23, 2009 12:28 pm

Re: disable some option in selectbox

Post by manohoo »

Code: Select all

$omit = array('notanoption','whatever'); // values to omit from check box	
// $result is an array containing key value pairs from database

foreach ($result as $key=>$value) {
   if (in_array($value, $omit) ) { } // do nothing
   else echo "<INPUT TYPE='checkbox' name='$key' value='$value'> </INPUT>";
}
Lphp
Forum Commoner
Posts: 74
Joined: Sun Jun 26, 2011 9:56 pm

Re: disable some option in selectbox

Post by Lphp »

thank
Post Reply