title: Javascript, error meassge expected object
body: <p>I have a problem with this code I am quite new to programming and not sure what I have done wrong. when the function is run from the web browser it says object expected however it worked before I added some code to it the addveh and remove</p>
  
  <p>puzzled sorry if this is the wrong place to post this </p>
  
  <pre><code>function ratech01(){
  var numcars = document.getElementById('numars').value; 
  var romcars = document.getElementById('removecars').value;
  var addcars = document.getElementById('addcars').value;
  var veh = 0;
  var addveh = 0;
  var removed = 0;
  var Decision = '&lt;span style="color:green"&gt;OK&lt;/span&gt;';
  var addloading = "(";
  var busload = 0;
  var inputload = +document.getElementById('load').value; 
  for (var i = 0; i &lt; numcars; i++){
       veh =  +veh + +document.getElementById('carval' + i).value;
  }
  for (var i = 0; i &lt; romcars; i++){
       remove =  +remove + +document.getElementById('romcarval' + i).value;
  }
  for (var i = 0; i &lt; addcars; i++){
       addveh =  +addveh + +document.getElementById('addcarval' + i).value;
  }   
  var addveh = addveh / 1000 * 5;
  var remove = remove / 1000 * 5;
  veh = veh / 1000 * 5;
  vehend = veh + remove;
  
  if (addveh != NaN || remove != NaN){
          if ( addveh != NaN &amp;&amp; remove != NaN){
              addveh = veh + addveh - remove;
          }else if( addveh != NaN){
          addveh = veh - remove;
      }else{
      addveh = veh + addveh;
      }   
  
      }else {
  
      }  
  
  if ( document.getElementById('club').value === "yes"){
  
      vehend = vehend + 41;
      addveh = addveh + 41;
      if (document.getElementById('inception').value === "no"){
      if ( vehend &lt; 60 || addveh &lt; 60){
  
          if ( vehend &lt; 60 &amp;&amp; addveh &lt; 60){
              vehend = 60;
              addveh = 60;
          }else if(vehend &lt; 60 ){
              vehend = 60;
          }else {
          addveh = 60;
          }
      }else{
      }
  
  }else{
      if ( vehend &lt; 76 || addveh &lt; 76){
  
          if ( vehend &lt; 76 &amp;&amp; addveh &lt; 76){
              vehend = 76;
              addveh = 76;
          }else if(vehend &lt; 76 ){
              vehend = 76;
          }else {
          addveh = 76;
          }
      }else{
      } 
  } 
  
  
  }else {
  
  
  
  
  
  
      vehend = vehend + 67;
      addveh = addveh + 67;
      if (document.getElementById('inception').value === "no"){
      if ( vehend &lt; 60 || addveh &lt; 60){
  
          if ( vehend &lt; 60 &amp;&amp; addveh &lt; 60){
              vehend = 60;
              addveh = 60;
          }else if(vehend &lt; 60 ){
              vehend = 60;
          }else {
          addveh = 60;
          }
      }else{
      }
  
  }else{
      if ( vehend &lt; 102 || addveh &lt; 102){
  
          if ( vehend &lt; 102 &amp;&amp; addveh &lt; 102){
              vehend = 102;
              addveh = 102;
          }else if(vehend &lt; 102 ){
              vehend = 102;
          }else {
          addveh = 102;
          }
      }else{
      } 
  }
  
  
  
  if ( document.getElementById('garage').value === "no"){
      if ( document.getElementById('area').value == 1){
  
      }else if ( document.getElementById('area').value == 2){
          var Decision = "Please refer";  
      }else if ( document.getElementById('area').value == 3){
          var Decision = '&lt;span style="color:red"&gt;Decline car must be garaged&lt;/span&gt;';
      }else{
          var Decision = '&lt;span style="color:red"&gt;Decline car must be garaged&lt;/span&gt;';
      }
  
  }   
  if ( document.getElementById('lience').value == 1){
      var Decision = '&lt;span style="color:red"&gt;Decline Driver must have licence more than 1 year&lt;/span&gt;';
  
  }else if ( document.getElementById('lience').value == 2){
      var addloading = addloading + '15% loading for 1-2 years driving &lt;br/&gt;';
      var year1 = vehend / 100 * 15;
      vehend = vehend + year1;
      var year2 = addveh / 100 * 15;
      addveh = addveh + year2;
  }
  
  if (inputload != ""){
      var addloading = addloading + " " + inputload + '% for user input) &lt;br/&gt;';
      var conload = vehend / 100 * inputload;
      vehend = vehend + conload;
      var conload2 = addveh / 100 * inputload;
      addveh = addveh + conload2;
  }else {
      var addloading = addloading + ")";
  }
  
  if ( document.getElementById('business').value === "yes"){
  
      var addloading = addloading + " " + '30% business use &lt;br/&gt;';
      var businload = veh / 100 * 30;
      var businload2 = addveh / 100 * 30;
      vehend = vehend + businload;
      addveh = addveh + businload2;
  }
  
      vehandipt = (vehend / 100 * 6) + vehend;
      addandipt = (addveh / 100 * 6) + addveh;
  
  document.getElementById('result').innerHTML = vehend + " " + Decision + " " + addloading + " " + vehandipt;
  
  
  }
  </code></pre>