title: Javascript math text field
body: <p>I'm trying to fiddle with an some easy maths in javaascript, but I don't get it to work and I am a real beginner in js.</p>
  
  <p>Basically I am just trying to use 'result1' as a variable for a second simple math, but it seems like it's not working that the id 'result' is accepted.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;input id="value1" type="text" onchange="output();" /&gt;
  &lt;span&gt; + &lt;/span&gt;
  &lt;input id="value2" type="text" onchange="output();" /&gt;
  &lt;span&gt; * &lt;/span&gt;
  &lt;input id="value3" type="text" onchange="output();" /&gt;
  &lt;p id="result1"&gt; &lt;/p&gt;
  
  
  &lt;span&gt; + &lt;/span&gt;
  &lt;input id="value5" type="text" onchange="output();" /&gt;
  &lt;p id="result2"&gt; &lt;/p&gt;
  
  &lt;script type="text/javascript" language="javascript" charset="utf-8"&gt;
  
  
  function output(){
      var value1 = document.getElementById('value1').value;
      var value2 = document.getElementById('value2').value;
      var value3 = document.getElementById('value3').value;
      document.getElementById('result1').innerHTML = (parseInt(value1) + parseInt(value2)) * parseInt(value3);
      var value4 = document.getElementById('result1').value;
      var value5 = document.getElementById('value5').value;
      document.getElementById('result2').innerHTML = parseInt(value4) + parseInt(value5);
       
  }
  
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>fiddle <a href="http://jsfiddle.net/8x7oq4o2/" rel="nofollow noreferrer">here</a></p>