asap ... auto save checked value when click on checkbox

[b]hi … i need help asap (code) please !!

iam using yii 1.1[/b]

[size="5"]i need to save checked value automatically without submit button or the same checkbox is submit; [/size]

  • when user checked checkbox : save 1 in database column.

  • when user unchecked checkbox : save 0 in database column.


Can you share your view file snippet?

in view:

<?php echo $form->switchGroup($model, 's_check_support',


				'widgetOptions' => array(


						'switchChange'=>'js:function(event, state) {

						  console.log(this); // DOM element

						  console.log(event); // jQuery event

						  console.log(state); // true | false





		); ?>

i need “code”, functions to active DOM element, jQuery event and state !! i don’t know any things about that.

but no problem if you have any ways to solve what i need (((change value in database auto. on click checkbox)))

if you have any description:

  • please tell me where i put any additional file

  • how to access to this file

  • with same this:

    • my column in database called: "s_check_support"

    • name of table: "admin_user"

    • name of data base: "govdb" -> no password.

    • i am use Yii 1.1


This code may help you


echo $form->switchGroup($model, 's_check_support', array(

    'widgetOptions' => array(

        'events' => array(

            'switchChange' => 'js:function(event, state) {

                                                  if($(this).is(":checked")){ //May vary based on the widget you are using

                                                    //Make your ajax request


                                                    //AJAX Response 








In your controller create a action or add a parameter to existing action and update the model