0

I have a js in a folder js. I call the file in the header.
I have the next code in my view:

<?php echo form_dropdown('mydropdown',$options) ?>

I need to pass the paramether $js, could you help me with the syntax?

$js = 'id="shirts" onChange="display(this,\'id1\',\'id2\');"';


<?php echo form_dropdown('mydropdown',$options, $js) ?>

When I see the source code of my dropdown I can't see the id="shirts", then I believe that the function javascript is not recognized.

What's my error. My codeigniter version is 2.0.

Thanks.

1
  • $js needs to be the 4th parameter. It's form_dropdown('name', $options, 'selected', $js); Commented Nov 21, 2011 at 16:33

1 Answer 1

1

javascript should be the fourth parameter to this call. So add a null parameter in the third (which is for the selected value of the dropdown):

<?php echo form_dropdown('mydropdown',$options, null, $js) ?>

http://ellislab.com/codeigniter/user_guide/helpers/form_helper.html

Sign up to request clarification or add additional context in comments.

Comments

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.