title: Calling checkbox only if checked
body: <p>i have a checkbox that toggled with a button
  but i also need to add the its value to an equation, ONLY IF its checked.
  what i got right now is this, but it just add regardless of whether the checkbox is checked or not</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script language=javascript&gt;
  function validate(chk){
    if (chk.checked == 1)
      chk.checked = 0;
    else
      chk.checked = 1; 
  }
  &lt;/script&gt;
  
  &lt;meta http-equiv="Content-Type" content="text/html;charset=utf-8"&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form name="myform"&gt;
  &lt;input type="checkbox" name="ghj" id="ghj" value="100000"&gt;testing sheep&lt;br&gt;
  &lt;input type="button" class="button-primary widget-control-save" name="Check_All" value="Check All" onmouseout="compute(this.form)" onClick="validate(ghj)"&gt;
  &lt;input type="text" id="rslt" name="rslt"&gt;
  &lt;/form&gt;
  &lt;script type="text/javascript"&gt;
  &lt;!-- hide this script from old browsers
  function compute(form)
  {
  var test = parseInt(document.getElementById('ghj').value, 10) || 0;
  f = (test + 10);
  
  document.getElementById('rslt').value = f;
  }
  
  // done hiding from old browsers --&gt;
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>if...else statements may work but if i have a longer form that would mean hundreds of possibilities, and i'd like a more efficient way..</p>