select multiple checkbox html code example

Example 1: html multiple checkbox list

<form method="post" action="/Tests/Post/">         
  <fieldset>              
    <legend>What is Your Favorite Pet?</legend>             
    <input type="checkbox" name="favorite_pet" value="Cats">Cats<br>             
    <input type="checkbox" name="favorite_pet" value="Dogs">Dogs<br>             
    <input type="checkbox" name="favorite_pet" value="Birds">Birds<br>             
    <br>              
    <input type="submit" value="Submit now" />          
  </fieldset>      
</form>

Example 2: multiselect checkbox

var expanded = false;

function showCheckboxes() {
  var checkboxes = document.getElementById("checkboxes");
  if (!expanded) {
    checkboxes.style.display = "block";
    expanded = true;
  } else {
    checkboxes.style.display = "none";
    expanded = false;
  }
}