I want to post a checkbox to action and print alert if the checkbox is checked, here is my code:
view:
echo CHtml::checkBox('hi');
echo CHtml::button('Search', array('onclick' => 'js:document.location.href="index"'));
controller:
public function actionIndex()
{
$model = Jobs::model()->findAll();
$model2 = Tags::model()->findAll();
if(isset($_POST['hi']))
echo "<script>alert('hello');</script>";
$this->render('index', array('model'=>$model, 'model2'=>$model2));
}
when I check the checkbox and click the button nothing is happened, where is the error in my code?