title: Javascript Text Input Calculator
body: <p>I am somewhat new to Javascript and I'm trying to make a basic calculator that has 3 text inputs, a 1st number text box, an operation textbox, and a second number textbox, but it doesn't print out the text when I click a button or use any other method to trigger the event.
  This is my code:</p>
  <pre><code>&lt;html&gt;
  &lt;script&gt;
  function calc()
  {
      var D = &quot;&quot;;
      var A = document.getElementById(&quot;num1&quot;).value;
      var B = document.getElementById(&quot;op&quot;).value;
      var C = document.getElementById(&quot;num2&quot;).value;
      if(B == &quot;+&quot;)
      {
          D = A+C;
      }
      elseif(B == &quot;-&quot;)
      {
          D = A-C;
      }
      elseif(B == &quot;*&quot;)
      {
          D = A*C;
      }
      elseif(B == &quot;/&quot;)
      {
          D = A/C;
      }
      document.getElementById(&quot;result&quot;).innerHTML = D;
  }
  &lt;/script&gt;
  
  &lt;body&gt;
      &lt;input type=&quot;text&quot; id=&quot;num1&quot; name=&quot;num1&quot; /&gt;
      &lt;input type=&quot;text&quot; id=&quot;op&quot; name=&quot;op&quot; /&gt;
      &lt;input type=&quot;text&quot; id=&quot;num2&quot; name=&quot;num2&quot; /&gt;
      &lt;br /&gt;
      &lt;input type=&quot;button&quot; value=&quot;Solve&quot; onclick=&quot;calc()&quot; /&gt;
  
      &lt;p id=&quot;result&quot; name=&quot;r1&quot;&gt;
          &lt;br /&gt;
      &lt;/p&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>