Its been a long time since I coded and it shows. Example problem is this.
I have three check box lines, two for Jim, and one for bob.
In the code test below, with Option A active, all three become checked (not want I want)
If Option B is active, it fails.
I'm using 'class' as the selector but could use any other in the HTML lines like "name" if that would work.
Your patience with this old man will be appreciated.
I have three check box lines, two for Jim, and one for bob.
In the code test below, with Option A active, all three become checked (not want I want)
If Option B is active, it fails.
Code:
jim<input class='jim' type="checkbox"/>
bob<input class='bob' type="checkbox"/>
jim<input class='jim' type="checkbox"/>
<div id="checkme">Check All</div>
<div id="uncheckme">Uncheck All</div>
<script>
function checkedAll(isChecked) {
/**** options for lines in test ********/
/* Option A */
var c = document.querySelectorAll('input[type="checkbox"]');
/* Option B */
//var c = document.querySelectorAll('input[class = ".jim"]');
/****************************************/
for (var i = 0; i < c.length; i++){
c[i].checked = isChecked;
}
}
checkme.addEventListener('click', function(){
checkedAll(true);
});
uncheckme.addEventListener('click', function(){
checkedAll(false);
});
</script>
I'm using 'class' as the selector but could use any other in the HTML lines like "name" if that would work.
Your patience with this old man will be appreciated.