I have several checkboxes in a form (all of the same name) 'delsel2' like this:
<input type="checkbox" name="delsel2" value="100">
<input type="checkbox" name="delsel2" value="101">
<input type="checkbox" name="delsel2" value="102">
I want to be able to simply bring up an alert when any of them are selected, and display a message indicating whether any of them are ticked, or not.
I have come up with this, but it doesn't work:
document.getElementById("delsel2").addEventListener("click", checkstate);
function checkstate(){
if (document.getElementById("delsel2").checked) {
alert("Checked");
} else {
alert("Not Checked");
}
}
But nothing happens? What am I doing wrong? Many thanks for any help.