title: What value passes from a form with checkbox to the java script
body: <p>I take a form and wants value of checkbox.
  such as:</p>
  
  <pre><code>&lt;form method="post" onSubmit="return nameempty()"&gt;
  
  &lt;input name="checkn1" id="check1" type="checkbox" /&gt;
  &lt;input name="checkn2" id="check2" type="checkbox" /&gt;
  
  &lt;input type="submit" value="submit"&gt;
  &lt;/form&gt; 
  </code></pre>
  
  <p>Now I want to know the values of checkbox when it is selected, and also when not selected.</p>
  
  <p>Now I write javascript, and get that each checkbox has value "on" whether it is selected or not.</p>
  
  <pre><code>&lt;script&gt;
  function nameempty()
  {
  alert(document.getElementById('check1').value);
  alert(document.getElementById('check2').value);
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>How could I get 'on' when it is selected and anything else when not selected.</p>