title: Not sure what is wrong with the function
body: <p>I am completely new to this and am trying to write a program which will take inputs on a webpage and score the results in an output box. I am not sure what the problem is with this set of javascript, though I am sure that I am missing an integral piece! Any help is much appreciated!</p>
  
  <pre><code>function laten() { 
  
  var Q2 = document.getElementById('twoScore').value;
  
  if (Q2 == "") {
      Q2 = 0;}
  
  var Q2new = 0;
  
  if (parseInt(Q2) &gt;= 0) &amp;&amp; (parseInt(Q2) &lt;= 15) {
      Q2new = 0;
  } else if (parseInt(Q2) &gt; 15) &amp;&amp; (parseInt(Q2) &lt;=30) {
      Q2new = 1;
  } else if (parseInt(Q2) &gt; 30) &amp;&amp; (parseInt(Q2) &lt;=60) {
      Q2new = 2;
  } else if (parseInt(Q2) &gt; 60) {
      Q2new = 3;
  }
  
  document.getElementById('latency').value = Q2new;
  
  var Q5a = document.getElementById('fiveaScore').value;
  
  if (Q5a == "") {
      Q5a = 0;}
  
  var latenAdd = parseInt(Q5a) + parseInt(Q2new);
  
  if (latenAdd == "") {
      latenAdd = 0;}
  
  var latenScore = 0;
  
  if (latenScore == "") {
      latenScore = 0;}
  
  
  if (latenAdd == 0) {
          latenScore = 0;
      } else if ((latenAdd &gt;= 1) &amp;&amp; (latenAdd &lt;= 2)) {
          latenScore = 1;
      } else if ((latenAdd &gt;= 3) &amp;&amp; (latenAdd &lt;= 4)) {
          latenScore = 2;
      } else if ((latenAdd &gt;= 1) &amp;&amp; (latenAdd &lt;= 2)) {
          latenScore = 3;
      }
  
  
  if (!isNaN(latenScore)) {
          document.getElementById('latency').value = latenScore;
  }
  </code></pre>