title: Using Javascript to calculate form fields -- get NaN as a result
body: <p>I have created a short form that is supposed to calculate values based on user input.  I've got most of it figured out but can't seem to get the results to show up in the totals field.  Instead, I get NaN.</p>
  
  <p>I'm trying to use parseInt but haven't had any luck yet.</p>
  
  <p>Here is what I have so far:</p>
  
  <p>The Javascript:</p>
  
  <pre><code> var AdPrice = document.getElementsByTagName('input') = 0;
    var ColorCharge = document.getElementsByTagName('input') = 0;
    var WebAd = document.getElementsByTagName('input') = 0;
    var AdSubtotal = 0;
    var DownPayment = document.getElementsByTagName('input') = 0;
    var TotalPrice = 0;
    var Payments = document.getElementsByTagName('input') = 0;
    var TotalPayment = 0; 
  
  function updateTotal()
  {
    var subtotal = AdPrice + ColorCharge + WebAd;
    var total = subtotal - DownPayment;
    var totalmonthlypayment = total / Payments;
  
   parseFloat(document.getElementById('AdSubtotal').value = subtotal);
   parseFloat(document.getElementById('TotalPrice').value = total);
   parseFloat(document.getElementById('Payment').value = totalmonthlypayment);
  
  
  }
  </code></pre>
  
  <p>The HTML:</p>
  
  <pre><code>&lt;fieldset&gt;
                &lt;legend&gt;Payment Details&lt;/legend&gt;
  
               Ad Charge $
  
                &lt;input type="text" name="AdPrice" id="AdPrice" class="medium" onChange="updateTotal()" /&gt;&lt;br /&gt;
  
                Color Charge +
  
                &lt;input type="text" name="ColorCharge" id="ColorCharge" class="medium" onChange="updateTotal()" /&gt;&lt;br /&gt;
  
                Web Ad +
                &lt;input type="text" name="WebAd" id="WebAd" class="medium" onChange="updateTotal()" /&gt;&lt;br /&gt;
  
                Subtotal =
  
                &lt;input type="text" name="AdSubtotal" id="AdSubtotal" readonly class="medium"  /&gt;&lt;br /&gt;
  
             Down Payment -
  
             &lt;input type="text" name="DownPayment" id="DownPayment" class="medium" onChange="updateTotal()" /&gt;&lt;br /&gt;
  
             Total = 
             &lt;input type="text" name="TotalPrice" id="TotalPrice" readonly class="medium"  /&gt;&lt;br /&gt;&lt;br /&gt;
  
  
  
             # Consec. Payments \
  
               &lt;input type="text" name="Payments" id="Payments" class="medium" onChange="updateTotal" /&gt;&lt;br /&gt;
  
              Amt Each Payment $ 
  
              &lt;input type="text" name="Payment" id="Payment" class="medium" readonly  /&gt;&lt;br /&gt;&lt;br /&gt;
  
              &lt;input type="checkbox" name="ProratedCheck" id="ProratedCheck" /&gt; &lt;span style="margin-right:10px;"&gt;Prorated/Length&lt;/span&gt;&lt;input type="text" name="ProratedLength" id="ProratedLength" /&gt;
  &lt;/fieldset&gt;           
  </code></pre>
  
  <p>I also have a fiddle:</p>
  
  <p><a href="http://jsfiddle.net/kjetterman/eHQV4/10/" rel="nofollow">http://jsfiddle.net/kjetterman/eHQV4/10/</a></p>