title: getting NaN message in javascript while adding up multiple text fields
body: <p>I am developing a simple application form where I am calculating experiences from maximum three employers. Now I want to add them up . The experiences are in the form of X years Y months and Z days. I have written following javascript function --</p>
  
  <pre><code>function total(){
      var td;
      var fd=parseInt(document.getElementById("LoS_days1").value);
      var sd=parseInt(document.getElementById("LoS_days2").value);
      var ld=parseInt(document.getElementById("LoS_days3").value);
      var tm;
      var fm=parseInt(document.getElementById("LoS_months1").value);
      var sm=parseInt(document.getElementById("LoS_months2").value);
      var lm=parseInt(document.getElementById("LoS_months3").value);
      var ty;
      var fy=parseInt(document.getElementById("LoS_year1").value);
      var sy=parseInt(document.getElementById("LoS_year2").value);
      var ly=parseInt(document.getElementById("LoS_year3").value);
      td = (fd +sd +ld);
      var rd = td%30;
      var cm = Math.floor(td/30);
      document.getElementById("Totalexp_day").value=rd;   
      tm = (cm + fm +sm +lm);
      var rm = tm%12;
      var cy = Math.floor(ty/12);
      document.getElementById("Totalexp_month").value=rm;
      ty = (cy + fy +sy +ly);
      document.getElementById("Totalexp_year").value=ty;
      }
  </code></pre>
  
  <p>I am getting a NaN message in each of the Totalexp_day, Totalexp_month and Totalexp_day field. Earlier I had some modified code that was not showing NaN message but it was not showing the desired results. Kindly suggest what to do to eliminate these two errors.</p>