Maybe you can help me with this:
I have a function that ads a div by a button click. Any div contains a checkbox and a text field. If the checkbox is checked the text field is green, if not, the text field is red.
I don't know how to assign a dynamic div name for the "procedure" div, as the counter, like id = procedure1, id=procedure2... and then access the background color as procedure1.style.backgroundColor...
Thank you!
var counter = 1;
function addInput(divName) {
var newdiv = document.createElement('div');
newdiv.innerHTML = "<input type='checkbox' id='check' onclick='if(this.checked){procedure.style.backgroundColor=`green`;}
else {procedure.style.backgroundColor=`red`;}'><input type='text' id='procedure'>";
document.getElementById(divName).appendChild(newdiv);
counter++;
}