Praditha Praditha - 4 months ago 38
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>
</select>


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

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