title: How to display alert boxes based on if a check box is checked or not using Javascript
body: <p>I am trying to make it so that if the checkbox on our page is checked it will display an alert message notifying the user they have opted in to showing their checkout history. If the user deselects the check box then it should show another alert box letting them know they are opting out of showing their checkout history. I am having trouble just displaying alert boxes if the check box is even checked/unchecked. Here is my code.</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;div class="myAccountCheckboxHolder" id="showCheckoutHistoryCheckbox"&gt;
      &lt;input tabindex="40" checked="checked" id="showCheckoutHistory" name="showCheckoutHistory" type="checkbox"&gt;
          &lt;label for="showCheckoutHistory" class="checkLabel"&gt;Show my checkout history&lt;/label&gt;
      &lt;/div&gt;    
  </code></pre>
  
  <p>Javascript</p>
  
  <pre><code>function validate() {
      var checkoutHistory = document.getElementById('showCheckoutHistory');
      if (checkoutHistory.checked) {
          alert("You have elected to show your checkout history.");
      } else {
          alert("You have elected to turn off checkout history.");
      }
  </code></pre>
  
  <p>Thank you.</p>