0

I am using form helper to create a dropdown menu, I have looked at http://codeigniter.com/user_guide/helpers/form_helper.html but it doesn't specify how to assign attributes to dropdown menu. I want to add id and class to my dropdwon menu. How do I do that? Thanks for the help.

My code

$JNarray=array(
'company1'=>'company1,
'company2'=>'company2
);

echo form_label("company");
echo form_dropdown('company',$JNarray);

The above will create

<select name='company'>  //I want to add 'id' and class attribute to select
  <option value='company1'>company1</option>
  <option value='company2'>company2</option>
</select>

1 Answer 1

1

You can do this with the fourth argument:

<?php
echo form_dropdown('company', $JNarray, NULL, 'id="company" class="some-class"');
Sign up to request clarification or add additional context in comments.

1 Comment

is there any way to add attribute to the certain "option"? I want to add 'disabled' attribute to some of opptions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.