JSFiddle - React, Tailwind, and code Playground
by solvomedia
HTML
<form id="checkForm">
<input type="checkbox" name="chkboxarray[]" /> First<br />
<input type="checkbox" name="chkboxarray[]" /> Second <br />
<input type="checkbox" name="chkboxarray[]" /> Third
</form>
JavaScript
function check_uncheck(truefalse){
var boxes = document.forms[0]["chkboxarray[]"].length;
var form = document.getElementById('checkForm');
for(var i=0;i < boxes;i++){
if (truefalse) {
form["chkboxarray[]"][i].checked=true;
} else {
form["chkboxarray[]"][i].checked=false;
}
}
}
//Code below this line is to illustrate the code above this line works as expected
var set_checked = true;
var timeout = window.setInterval(function () {
check_uncheck(set_checked);
set_checked = !set_checked;
}, 2000);