vendredi 21 avril 2017

Issues running a function off a checkbox onclick

I'm trying to figure out how to make an onclick checkbox function so I thought I would make a small little example. Of course I can't see what i'm doing wrong. Any help would be appreciated.

<!DOCTYPE html>
<html>

<title>Pizza Test</title>
  <script>
      function validatePizza(){
        if(document.getElementById('pepperoni' && 'sausage' && 
        'olives').checked = false)
          message.innerText = "What a terrible pizza";
      } else {
        message.innerText = "Exactly right";
      }
</script>

<h1>Which Pizza Ingredients are the best?</h1>

<h2>Pick which ingredients you like on your pizza</h2>
 <div id="ingredient_box">
  <input  type="checkbox"  id="pepperoni" value="pepperoni" 
  onclick="validatePizza();"/>
  <label for="pepperoni">Pepperoni</label>

  <input  type="checkbox"  id="sausage" value="sausage"/>
  <label for="sausage">Sasuage</label>

  <input  type="checkbox"  id="olives" value="olives"/>
  <label for="olives">olives</label>

  <input  type="checkbox"  id="mushrooms" value="mushrooms"/>
  <label for="mushrooms">mushrooms</label>

  <input  type="checkbox"  id="pineapple" value="pineapple"/>
  <label for="pineapple">pineapple</label>

  <input  type="checkbox"  id="greenPeppers" value="greenPeppers"/>
  <label for="greenPeppers">greenPeppers</label>




Aucun commentaire:

Enregistrer un commentaire