Iam trying to show/hide a div based on the radio button click in Yii form. But the onclick event is not working for me. Please help me to fix this as Iam a new bee to Yii. Iam using this code for radio button
<?php echo $form->radioButtonList($model,'service_type',array(
'0'=>'Yes',
'1'=>'No',
'separator'=>'',
'onclick'=>"setVisible('Yes_box',true);setVisible('No_box', false)")); ?>
<div id="Yes_box" style="visibility: hidden"> contents of Yes type </div>
<div id="No_box" style="visibility: hidden"> contents of No type </div>
This is my script:
<script>
$(document).ready(function () {
$("input[name$='type']").click(function () {
var value = $(this).val();
if (value == 'Yes') {
$("#Yes_box").show();
$("#No_box").hide();
} else if (value == 'No') {
$("#No_box").show();
$("#Yes_box").hide();
}
});
$("#Yes_box").show();
$("#No_box").hide();
});
</script>
When Iam using this code only the last condition is working i.e, Yes_box is showing. I think the onclick value is not passing here. Please help me to recover this problem.