Popup A Window If Checkbox Is Checked In Yii

I will appreciate if somebody could help me to find how to solve out one problem, I have a checkbox in my create form. If i pushed the create button I want to have a popup window if the checkbox is checked and do nothing if the checkbox is unchecked.

Here is what I started.

[sub]<?php echo $form->checkBoxRow($model, ‘default’); ?>

<div class="form-actions">

&lt;?php &#036;this-&gt;widget('bootstrap.widgets.TbButton', array(


    'buttonType'=&gt;'submit',


    'type'=&gt;'primary',


    'label'=&gt;&#036;model-&gt;isNewRecord ? 'Create' : 'Save',


)); ?&gt;

</div>[/sub]

Hi

add javascript code to do that

tried it already sir. i tried it like this… in my button create.


<?php $this->widget('bootstrap.wigets.TbButton', array(

            'buttonType'=>'createday',

            'type'=>'primary',

            'label'=>'Create new day',

            'htmlOptions'=>array(

                'onclick'=>"{addDay(); $('#dialogDay').dialog('open');}",

                'data-target'=>'#dialogDay',

            )

    ))

?>

this is my cjuidialog


<?php

$this->beginWidget('zii.widgets.jui.CJuiDialog', array( // the dialog

    'id'=>'dialogDay',

    'options'=>array(

        'title'=>'Create Day',

        'autoOpen'=>false,

        'modal'=>true,

        'width'=>550,

        'height'=>600,

    ),

));?>

<div class="divForForm"></div>


<?php $this->endWidget();?>

this is my javascript


<script type="text/javascript">

    function addModal()

    {

        if (($('#default').prop("checked"))){

            <?php echo CHtml::ajax(array(

                'url'=>array('day/create'),

                'data'=>"js:$(this).serialize()",

                'type'=>'post',

                'dataType'=>'json',

                'success'=>"function(data)

                {

                    if(data.status == 'failure')

                    {

                    $('#dialogDay div.divForForm').html(data.div);

                    $('#dialogDay div.divForForm form').submit(addModal);

                    }

                    else

                    {

                        $('dialogDay div.divForForm').html(data.div);

                        setTimeout(\"$('#dialogDay').dialog('close') \",3000);

                     }

                     }",

                     ))?>

            return false;

        }

        else {}//show some notification or what you want here

        }





    </script>

this is my actioncreate.


public function actionCreate()

    {

        $model=new Day;


        // Uncomment the following line if AJAX validation is needed

        //$this->performAjaxValidation($model);


        if(isset($_POST['Day']))

        {

            $model->attributes=$_POST['Day'];

            if($model->save())

            {

                if(Yii::app()->request->isAjaxRequest)

                {

                    echo CJSON::encode(array(

                        'status'=>'success',

                        'div'=>"Classroom successfully added"

                    ));

                    exit;

                }

                else

                    $this->redirect(array('view','id'=>$model->id_day));

            }


        }

        if(Yii::app()->request->isAjaxRequest)

        {

            echo CJSON::encode(array(

                'status'=>'failure',

                'div'=>$this->renderPartial('_form',array('model'=>$model),true)));

            exit;

        }

        $this->render('create',array(

            'model'=>$model,

        ));


    }

it displays data and immediately proceeds to submitting the data. what I want is if the checkbox is checked display the modal and inside that modal it displays something and there is submit button there. if the checkbox is not checked, submit the data immediately.