title: Display result of computation (javascript) in HTML
body: <p>I am trying to take two numbers from html and using javascript return sum of both but my num1 and num2 contains HTMLInputElement??</p>
  
  <p>html:</p>
  
  <pre><code>&lt;head&gt;
          &lt;script type ="text/javascript" src="functions.js"&gt;&lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
          Value 1: &lt;input type="text" id="tb1" name="tb1"&gt;&lt;br/&gt;
          Value 2: &lt;input type="text" id="tb2" name="tb2"&gt;&lt;br/&gt;
          Result: &lt;input type="text" id="tb3" name="tb3"&gt;&lt;br/&gt;
          &lt;button onclick="validateForm()" Type="button" id="b1" name="b1"&gt;Go&lt;/button&gt;
      &lt;/body&gt;
  </code></pre>
  
  <p>javascript:</p>
  
  <pre><code>function validateForm() {
      var x = document.getElementById("tb1");
      var y = document.getElementById("tb2");
      if (x == null || x == "" || y == null || y == "")
      {
          alert("Value cannot be empty");
          return false;
      }
      else {
          //myAdd(x,y);
          alert(x + y);
          var num1 = parseFloat(x);
          var num2 = parseFloat(y);
          var total = num1 + num2;
          document.getElementById("tb3").innerHTML = total;
      }
  }
  </code></pre>