title: Checking if checkboxes and radios are checked
body: <p>I've been through nearly every answer on this topic and I've had a hard time coming up with a solution.</p>
  
  <p>Basically, I'm trying to click a button that runs a function which checks to see if a radio button or check box is selected. </p>
  
  <p>Later one I'd like to be able to test for different combinations of these selections. </p>
  
  <p>This is the code. </p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
    &lt;script type = "text/javascript"&gt;
      function custom_urls(){
        var option1 = document.getElementById("option1");
        var option2 = document.getElementByid("option2");
        var bonus = document.getElementByid("bonus");                                          
  
        if ( option1.checked ){
          alert("Option1 is checked!");
        }
      }
  
  
    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;input type = "radio" id = "option1" &gt; Option1 &lt;/input&gt;&lt;/br&gt;
    &lt;input type = "radio" id = "option1" value = "option2"&gt; Option2 &lt;/input&gt;&lt;/br&gt;
    &lt;input type = "checkbox" id = "bonus" value = "bonus"&gt; Bonus &lt;/input&gt;&lt;/br&gt;
    &lt;button type = "button" onclick = "custom_urls()"&gt;Click Me&lt;/button&gt; 
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I've also tried putting:</p>
  
  <pre><code>if(option1.checked == true)
  </code></pre>
  
  <p>and</p>
  
  <pre><code>if(document.getElementById("option1").checked == true)
  </code></pre>
  
  <p>Thanks!</p>