So im trying to achieve this:
By using a list of checkboxes. With this code:
function test(){
checkbox[i].addEventListener("change", function(){
if(checkbox[i].checked){
document.getElementById("table").rows[i].style.backgroundColor = '#66EE27';
}
else{
document.getElementById("table").rows[i].style.backgroundColor ='white';
}
}, false)}
i could get it to work, but only if i is a pre defined index. I tried to insert a for loop but it didnt work. I also tried to make test() as recursive function and also didn't work.
So, as it is it can only change the color of specific index, and i would like for it to be for any index. I dont have the elements in HTML cause i created them with JS, getting info from database to see how many i would need by how many elements was in database.
If anyone can help, i would appreciate. Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire