Praditha Praditha - 1 year ago 143
PHP Question

How to set id or name in select option tag using CodeIgniter form helper

How to create this html tag using form helper on codeigniter,.?

<select id='list_city' name='city'>
<option id='city' value='0'>Bandung</option>
<option id='city' value='1'>Cimahi</option>

The concern of this question is how to set id='city' in option using CI Form_Helper. I need to set the id, because I'll use it in javascript later.

Answer Source

form_dropdown('country', $countryList, set_value('country', 'id="country" style="height: 30px;"'); ?>
here countryList is an array where as key you put the option value and the value of each key is shown up on select option

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download