I cant seem to get these checkboxes to work properly. I want to check each of these checkboxes to see if there checked, then im going to use that data to run another snippet of code later on in my program. Problem is, no matter if the checkbox is checked or not it always returns an undefined value.
This is the function in JS.
function meal_update_multi() {
let multimeal = document.getElementsByName('breakfast')
let brek = document.getElementById('#breakfast_selector')
let lunch = document.getElementById('#lunch_selector')
let din = document.getElementById('#dinner_selector')
if (multimeal.checked) {
console.log('YOU CHECKED ALL THE BOXES DUMMY')
}
else
alert('YOU DID NOT CHECK ALL THE BOXES')
console.log(multimeal.checked)
}
This is the HTML its paired with
<form id = 'remove_meal_mutiple_choice' onsubmit = 'return false'>
<h1>What Meals do you want to remove?</h1>
<input type = 'checkbox' name = 'breakfast' id = 'breakfast_selector'>
<label for = 'breakfast_selector'>Breakfast</label>
<input type = 'checkbox' name = 'lunch' id = 'lunch_selector'>
<label for = 'lunch_selector'>Lunch</label>
<input type = 'checkbox' name = 'dinner' id = 'dinner_selector'>
<label for = 'dinner_selector'>Dinner</label>
<button class = 'submit' type = 'submit' onclick = 'update_meals()'>Submit</button>
</form>