Reputation: 41
I am using an asp.net gridview control in a child page. The grid has two adjacent check box columns with the boxes in the second column disabled on startup. When a user checks a box in a row in the first column, the adjacent check box becomes enabled. My code below works fine in Chrome and FoxFire but not in IE 10 or 11. In order to check my syntax, I added an alternative response whereby the adjacent check box becomes clicked rather than enabled. This does work in IE. So, it seems IE is able to recognize and change he "Checked" property but not the "Disabled" property. I tried substituting "attr" for"prop" but got the same results. Also the same result when I substituted the "click" event for the "change" event. Is there a workaround for the IE browser? Thanks for your help.
Ken McLean
<script type="text/javascript">
$(document).ready(function() {
var chx = $('input[type="checkbox"]');
chx.change(function() {
var i = chx.index(this);
if (this.id.endsWith("chkCourse")) {
if ($(this).is(":checked")) {
//$(chx[i + 1]).prop("checked", true); this works in IE
$(chx[i + 1]).prop( "disabled", false ); // this does not
}
else {
//$(chx[i + 1]).prop("checked", false); this works in IE
$(chx[i + 1]).prop( "disabled", true ); // this does not
};
};
});
});
</script>
Upvotes: 0
Views: 962
Reputation: 41
I found a solution to my problem elsewhere on StackOverFlow. I was using ASP.Net Checkboxes. Here is the solution:
An is rendered as a with an and a tag. When the checkbox is disabled both the span and the input tags are decorated with the disabled attribute. To get the expected behavior I used to the following code:
$('myCheckBox').removeAttr('disabled'); $('myCheckBox').closest('span').removeAttr('disabled');
Upvotes: 1