In yii framework, you can make a dropdownlist (or select) as follows:
<?php
echo CHtml::dropDownList('select_id','',
$data,
array(
'prompt'=>'Select',
)
)
?>
where data is the array in the form of key=>value.
But what if you have to put here a 'onchange' event or styling too with chtml dropdown list. It can be done as follows:
<?php
echo CHtml::dropDownList('select_id','',
$data,
array(
'prompt'=>'Select a Industry',
'style'=>'width:250px',
'onchange'=> 'myFunc()',
)
)
?>
Now, on change of the dropdown list, it will call a javascript function myFunc().
<?php
echo CHtml::dropDownList('select_id','',
$data,
array(
'prompt'=>'Select',
)
)
?>
where data is the array in the form of key=>value.
But what if you have to put here a 'onchange' event or styling too with chtml dropdown list. It can be done as follows:
<?php
echo CHtml::dropDownList('select_id','',
$data,
array(
'prompt'=>'Select a Industry',
'style'=>'width:250px',
'onchange'=> 'myFunc()',
)
)
?>
Now, on change of the dropdown list, it will call a javascript function myFunc().
No comments:
Post a Comment