javascript - How can I insert ternary operation in 4th parameter in form_dropdown function in codeigniter?
367
I want my javascript onchange function not to be called whenever my$at_row[0]->ID
is true. The javascript onchange function call was placed in my form_dropdown function. I have tried my code but it wasn't working at all and prompts errors. How could I do this right? Here is my code.
Working code
<?php echo form_dropdown('at[brgy1]',$dropdown_brgy1,(isset($at_row[0]->ID)) ? $at_row[0]->brgy1 : '',"id=brgy_id_1 class=form-control style=width:300px onchange=javascript:change_barangay_2(); "); ?>
Not working code
<?php echo form_dropdown('at[brgy1]',$dropdown_brgy1,(isset($at_row[0]->ID)) ? $at_row[0]->brgy1 : '',"id=brgy_id_1 class=form-control style=width:300px "(isset($at_row[0]->ID)) ? return false : "onchange=javascript:change_barangay_2()";" "); ?>
Answer
Solution:
You are using ternary operator wrongly, the
return false
doesn't make any sense the current context, you just have to put empty string""
instead so that if condition expression is true, nothing will be appended to the string.here is the statement that should work.