title: Javascript alert on incomplete variables
body: <p>i'm having troubles on javascript arithmetic.
  lets say i have 2 elements from html,</p>
  
  <pre><code>var num1 = document.getElementByID('one').value;
  var num2 = docuemnt.getElementByID('two').value;
  
  var total = num1 + num2;
  
  alert(total);
  </code></pre>
  
  <p>these two elements are inputted by users. lets say the user left the id='one' blank. how do i make javascript still compute and alert 'total'? can javascript  automatically set the blank field to '0'? i tried this on my project but it will only give me an alert if both 'one' and 'two' were given/inputted. maybe i'm missing something.</p>
  
  <p>Thanks for any help.</p>
  
  <p><strong>ok this is the code i'm using on my project,</strong></p>
  
  <pre><code>var number = document.getElementById('child1').value;
  var hrs = document.getElementById('hrs1').value;
  var qty = document.getElementById('qty1').value;
  var watts = qty * (number / 1000);
  var kwh = watts * hrs;
  var kwhh = kwh * 30;
  
  var number2 = document.getElementById('child2').value;
  var hrs2 = document.getElementById('hrs2').value;
  var qty2 = document.getElementById('qty2').value;
  var watts2 = qty2 * (number2 / 1000);
  var kwh2 = watts2 * hrs2;
  var kwhh2 = kwh2 * 30;
  
  var totalperhr = kwh+kwh2;
  var totalper30 = kwhh+kwhh2;
  
  alert(totalperhr + ' kwh per day\n' + totalper30 + ' kwh per 30 days');
  </code></pre>
  
  <p>html below,</p>
  
  <pre><code>&lt;input type="range" min="1" max="1000" id="child1"&gt;
  &lt;select id="hrs1"&gt;
      &lt;option value='1'&gt;1hr&lt;/option&gt;
      &lt;option value='2'&gt;2hr&lt;/option&gt;
      &lt;option value='3'&gt;3hr&lt;/option&gt;
  &lt;/select&gt;
  &lt;select id="qty1"&gt;
      &lt;option value='1'&gt;1&lt;/option&gt;
      &lt;option value='2'&gt;2&lt;/option&gt;
      &lt;option value='2'&gt;3&lt;/option&gt;
  &lt;/select&gt;
  
  &lt;input type="range" min="1" max="1000" id="child2"&gt;
  &lt;select id="hrs2"&gt;
      &lt;option value='1'&gt;1hr&lt;/option&gt;
      &lt;option value='2'&gt;2hr&lt;/option&gt;
      &lt;option value='3'&gt;3hr&lt;/option&gt;
  &lt;/select&gt;
  &lt;select id="qty2"&gt;
      &lt;option value='1'&gt;1&lt;/option&gt;
      &lt;option value='2'&gt;2&lt;/option&gt;
      &lt;option value='2'&gt;3&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>as you can see, i'm going thru several operations then getting the grand total. but i'm not getting any alerts if i leave one blank.</p>