dimanche 17 janvier 2021

Why doesn't this code work to get the checked checkbox?

function selectedClass(){
if(!empty($_POST['checklist_class'])) {                  
    foreach($_POST['checklist_class'] as $id) {
       //stuff
    }
}

}

I've used identical code for another set of checkboxes and it works, but when i try it with the one below it doesn't. I would really appreciate some help! Here's the HTML code:

 <div class="multiselect">
            <div class="selectBox" onclick="showCheckboxes()">
              <select>
                <option>Choose classes</option>
              </select>
              <div class="overSelect"></div>
            </div>                
            <div id="checkboxes">
              <label for ='1'>
              <input type = 'checkbox' name = 'checklist_class[]' value = '1'> One
              </label>
              <label for ='2'>
              <input type = 'checkbox' name = 'checklist_class[]' value = '2'> Two
              </label>
              <label for ='3'>
              <input type = 'checkbox' name = 'checklist_class[]' value = '3'> Three
              </label>                  
            </div>
          </div>



Aucun commentaire:

Enregistrer un commentaire