I am trying to change the background color of a label in each checkbox in a form based on the checked/unchecked state of the checkbox.So far I got it to change initially, but it
There are couple of mistakes, in your script.
This is how you JS method should look like
function statecheck(layer, checkbox) {
var myLayer = document.getElementById(layer);
//myLayer.style.backgroundColor = "#bff0a1";
if(checkbox.checked == true){
myLayer.style.backgroundColor = "#bff0a1";
} else {
myLayer.style.backgroundColor = "#eee";
};
}
HTML