I want to disable a section of checkboxes if the "not interested" check box is clicked. below is my code:
<div>
<input style="margin-left:30px" id="notInterest" type="checkbox" name="test" onclick="Reassign(this)"> Not Interested
</div>
<div class="form-group row" id="reassignChecks">
@for (var i = 1; i <= 10; i++)
{
<input name="AreChecked" type="checkbox" value="@i" /> @i
<br />
}
<button>Click</button>
</div>
I have the following JavaScript:
function Reassign(cb) {
if (cb.checked == true) {
document.getElementById('reassignChecks').disabled = true;
} else {
document.getElementById('reassignChecks').disabled = false;
}
}
if I click on "Not Interested" check box then I want to disable the entire section that has an ID of "reassignChecks", but with the above JavaScript, this is not working. I dont want any of the checkboxes to be clicked in the reassignChecks section if Not Interested check box is clicked. below is the screen shot:
3
Answers
First:For a div dom ,it has not a disable attribute for you to control disable;
Second: You should realize this by add or remove a css from the div,the css property is pointer-events
and other color properties to imitate the disable function
Try this one-
Try this code.