jquery - Enable or Disable selectboxes with radio buttons -
i have set of radio buttons , set of select boxes dynamically generated through php code using same class name respective radio button , select box like.
<input type="radio" name="selop" class="1111" /> <select name="selval" class="1111"><options><!--all options--></options></select> <input type="radio" name="selop" class="2222" /> <select name="selval" class="2222"><options><!--all options--></options></select> <input type="radio" name="selop" class="3333" /> <select name="selval" class="3333"><options><!--all options--></options></select> <input type="radio" name="selop" class="4444" /> <select name="selval" class="4444"><options><!--all options--></options></select>
in case name radios , name of select boxes same , class names each set same.
i want if 1 checked radio select box of same class should enabled , rest should disabled.
i tried way didn't work me.
var $radio = $('input[name=selop]:checked'); var cname = $radio.attr('class'); var classname = "." + cname; $(classname).removeattr('disabled');
try:
first when radio button state change, add disabled attribute select box , remove attribute particular select box
$(function () { $('input[name=selop]').on('change', function () { var $radio = $('input[name=selop]:checked'); var cname = $radio.attr('class'); var classname = "." + cname; //console.log(cname); $('select[name=selval]').attr('disabled', 'true'); $(classname).removeattr('disabled'); }); });
Comments
Post a Comment