CHtml::dropDownList(CHtml::getActiveId($model,'component_id'),2,array(1=>'A',2=>'B'),array('onchange'=>'javascriptFunction();'));
//
<script>
function javascriptFunction(){
[[CODE FOR ONCHANGE HERE.]]
var value=$('#ModelName_component_id').val();
[...]
}
</script>
I do have date picker widget element in my form along with my other form elements,for the widget Yii is including jquery file and then writing a jquery function. In the jquery function all the html element events are written.
Now instead of writing one more jquery function(in my view file), i need to keep all my custom script and Yii generated script in one place i.e at the end of the page where yii is writing default script. How can i combine my custom script with yii generated jquery script function.
Above solution worked fine, but i need a bit more help, how can i send all the select box option values to server irrespective of it is selected or not. I am trying to do this in jquery.
if we go to “data” parameter there is ‘usersin’ variable where i am trying to get all values of selectbox into an array and then send it server, i tried using map function of jquery but its giving client side errors, how can i fix this.
the above code will populate a virtual input array with the values of your select options, then all you have to do, is to send that input with ajax, like:
var selectOptionsData=$('input[name=checkboxValues[]]').serialize();
[...]
$.ajax({
"data":selectOptionsData,
});
[...]