So I have this radiobutton with 2 options, Package
and Service
How can I enable or disable the respective dropDownList when the radiobutton is clicked.
I have this:
<?php echo $form->radioButtonList($model, 'option', array('0'=>'Packaged Services', '1'=>'Individual Services'), array(
'labelOptions'=>array('style'=>'display:inline'),
'separator' => " | ",
)
);
And my JQuery:
function disableBox(){
if ($('#Booking_option') == '0'){
$('#Booking_clientPackagedservice_id').prop('disable', false);
$('#Booking_service_id').prop('disable', true);
}
else if ($('#Booking_option') == '1'){
$('#Booking_clientPackagedservice_id').prop('disable', true);
$('#Booking_service_id').prop('disable', false);
}
}
How can I call the function disableBox
in the radioButtonList
?
Please advise. Thanks
Your question isn't related to yii realy. It's completely a javascript question and therefore has javascript based solutions. However, I think you should have an event handler for clicking on radiobutton
:
$(document).ready(function(){
$('input[type=radio]').change(function(){
if(this.value == /* something */)
disableBox();
else
//function for enabling dropDownList
});
})