I have this script in my html that dynamically adds an event handler to checkboxes but the problem is when the checkbox is clicked it doesnt return the value that was used in the called function but rather returns the total amount of items in the array of checkboxes.
<script>
var channelV = document.querySelectorAll('input');
function loadstart(){
for(var i = 0; i < 4; i++) {
channelV[i].addEventListener('change', function(){
SwitchChannel(i);
});
alert(i);
}
}
</script>
Not all my scripts are included.