title: Need help making a calculator using AJAX
body: <p>This is part of my assessment and we have to use JavaScript HTML and PHP to make a calculator with buttons, <strong>not fields</strong>.</p>
  
  <p>I have managed to make the 'interface' but cannot workout how to make the buttons work. I need the numbers to show in the input field (has to be readonly)</p>
  
  <p>What I'm asking for is help with making the buttons I've created show in the input field:</p>
  
  <blockquote>
    <p>I need to show the input within the text field</p>
  </blockquote>
  
  <p><strong>HTML</strong>
      
      
      
      
      </p>
  
  <pre><code>&lt;/head&gt;
  &lt;body&gt;
      &lt;input id="ip1" type="text" readonly="readonly"/&gt;&lt;br/&gt;
      &lt;button&gt;1&lt;/button&gt;
      &lt;button&gt;2&lt;/button&gt;
      &lt;button&gt;3&lt;/button&gt;
      &lt;button&gt;CE&lt;/button&gt; &lt;/br&gt;
      &lt;button&gt;4&lt;/button&gt;
      &lt;button&gt;5&lt;/button&gt;
      &lt;button&gt;6&lt;/button&gt;
      &lt;button&gt;/&lt;/button&gt; &lt;br&gt;
      &lt;button&gt;7&lt;/button&gt;
      &lt;button&gt;8&lt;/button&gt;
      &lt;button&gt;9&lt;/button&gt;
      &lt;button&gt;*&lt;/button&gt; &lt;/br&gt;
      &lt;button&gt;0&lt;/button&gt;
      &lt;button&gt;-&lt;/button&gt;
      &lt;button&gt;+&lt;/button&gt;
      &lt;button&gt;=&lt;/button&gt; &lt;/br&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>JavaScript</strong> (jQuery)</p>
  
  <pre><code>&lt;script&gt;
      $(document).ready(function() {
          $("button").click(function()  {
              $.post("calc.php",  { formText : $("#ip1").val()  },
                  function(data, status) {  $("#ip1").val(data);
              });
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>PHP</strong></p>
  
  <pre><code>&lt;?php
      $_POST['formText'];
  ?&gt;
  </code></pre>