My radio buttons looks like this
<div id="removeModal-85934">
<input type="radio" name="AdsArchive[status]" checked="checked" value="1" id="AdsArchive_status-85934">
<input type="radio" name="AdsArchive[status]" value="2" id="AdsArchive_status2-85934">
</div>
when AdsArchive_status-85934
is checked, it should enable a dropdown menu with id media-85934
and vise versa
here is my javascript
Yii::app()->clientScript->registerScript("delete-modal-js".$model->id, "
$( \"#removeModal-$model->id input[name=AdsArchive[status]]\").click(function() {
var val = $( \"#removeModal-$model->id input[name=AdsArchive[status]]:checked\").val();
if (val === 1) {
$(\"#media-$model->id\").attr('disabled',false);
$(\"#date_sold-$model->id\").attr('disabled',false);
}
else {
$(\"#media-$model->id\").attr('disabled',true);
$(\"#date_sold-$model->id\").attr('disabled',true);
}
});
");
i have multiple <div id="removeModal-85934">
in the same page. where 85934
is the id that changes. if possible i'd like a generic code for all the radio button so i don't have to add the $model->id
in my jquery on click.
right now when i click on the radio, button the dropdown menu is neither enabled or disabled, any idea what i'm doing wrong here?