'Please select' in populated dropdown

lori19

Active Member
Hi there!

Maybe this is usefull for someone:

My users often ignore to select an option from a dropdown that I populate via the advanced featrue. becuase the first option is already there. I could simply validate for this first option, but what if they actually selected it? And my options a re even entirley customised by the users in another list.
So I introduced a "Please select" with the value of 0 at the top of the list that makes it easy to validate.

$db =\Joomla\CMS\Factory::getContainer()->get('DatabaseDriver');
$db->setQuery('SELECT name FROM courses ORDER BY name');
$rows = $db->loadObjectList();
$myoptions[0] = JHTML::_('select.option','0','Please select');
foreach ($rows as $row) {
$myoptions[] = JHTML::_('select.option', $row->name, $row->name);
}
return $myoptions;​
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top