How to document.write() String from array, using for loop that will check if the checkboxes are selected. My example down isn't working. It works manually without for loop, so I assume that the problem is in loop.
<div style="width:100%"><input type="checkbox" id="cb1"></div>
<div style="width:100%"><input type="checkbox" id="cb2"></div>
<div style="width:100%"><input type="checkbox" id="cb3"></div>
<div style="width:100%"><input type="submit" id="execute" value="Execute" onClick="run();"></div>
submit.js
function run() {
myArr = [" ","You selected first checkbox", "You selected second checkbox", "You selected the last one"];
snip = "<div>HERE GOES YOUR CHECKBOX CHOICE: </div>";
for(m=1;m<4;m++) {
if(document.getElementById("cb[m]").checked == true) {
snip += "<br/> - " + myArr[m];
}
document.write(snip);
}
}
document.write()statements will clear the current document and start a new empty document?