title: Changing Text in Javascript
body: <p>I am not asking anybody to code for me. Please just tell me what I am missing or what I have done wrong with my codes.  </p>
  
  <p>My javascript program should run like this: </p>
  
  <ol>
  <li>Upon pressing a button, a simple multiplication table should appear and overwrite the words "The Table should be here".</li>
  <li>Pressing another button, another simple multiplication button should appear and overwrite the previous multiplication table. </li>
  </ol>
  
  <p>I am able to make the multiplication tables come out but the problem is, it does not overwrite the previous table. It just creates another table at the bottom of the previous one. Please Help. This is not a home work.. I am very new and just trying to learn all the possibilities of creating a somewhat complex program using simple codes.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function x()
      {
          var a=1;
          for(a=0;a&lt;=10;a++)
          {
              var total = 2 * a;
              var newHeading = document.createElement("p");
              var h1Text = document.createTextNode("2 x " + a + " = " + total);
              newHeading.appendChild(h1Text);
              document.getElementById("dname1").appendChild(newHeading);
          }
      }
  
      function y(total)
      {
          var a=0;
          for(a=0;a&lt;=10;a++)
          {
              var total = 3 * a;
              var newHeading = document.createElement("p");
              var h1Text = document.createTextNode("3 x " + a + " = " + total);
              newHeading.appendChild(h1Text);
              document.getElementById("dname2").appendChild(newHeading);
          }
      }
      &lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
  
      &lt;h1&gt;Date and Hours&lt;/h1&gt;
     &lt;p&gt;Click a button&lt;/p&gt;
     &lt;p id="dname1"&gt;Table of 2 should be here&lt;/p&gt;
      &lt;p id="dname2"&gt;Table of 3 should be here&lt;/br&gt;&lt;/p&gt;
  
     &lt;button type="button" onclick="x()"&gt;Table of Two&lt;/button&gt;
     &lt;button type="button" onclick="y()"&gt;Table of Three&lt;/button&gt;
  </code></pre>