CodeIgniter Forums

Full Version: How shall i add class[CSS] in dropdown
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

This is the way to create drop down in codeigniter:
$options = array(
'small' => 'Small Shirt',
'med' => 'Medium Shirt',
'large' => 'Large Shirt',
'xlarge' => 'Extra Large Shirt',
echo form_dropdown('shirts', $options, 'large');

How shall i add class[CSS] for this which will produce:
<select name="shirts" class="listShift">

For your kind information i need the solution of Class not Style.


El Forum

There is a fourth parameter where you can add a string with attributes. In your case it would be
$options = array(
‘small’ => ‘Small Shirt’,
‘med’ => ‘Medium Shirt’,
‘large’ => ‘Large Shirt’,
‘xlarge’ => ‘Extra Large Shirt’,
echo form_dropdown(’shirts’, $options, ‘large’,'class="listShift"');

El Forum

Thanks..... This is exactly what i was searching. Thanks.