I want to enable or disable checkbox in table\'s row on basis of condition.
code -
-
I know this question is a little old but here is my solution.
// HTML
//
//
// cb1 = checkbox 1
// cb2 = checkbox 2
var cb1 = getId('cb1'),
cb2 = getId('cb2');
function getId(id) {
return document.getElementById(id);
}
function setcb1() {
if(cb1.checked === true) {
cb2.checked = false;
cb2.disabled = "disabled"; // You have to disable the unselected checkbox
} else if(cb1.checked === false) {
cb2.disabled = ""; // Then enable it if there isn't one selected.
}
}
function setcb2() {
if(cb2.checked === true) {
cb1.checked = false;
cb1.disabled = "disabled"
} else if(cb2.checked === false) {
cb1.disabled = ""
}
Hope this helps!
- 热议问题