title: printing using document.getElementById("demo").innerHTML
body: <p>I have the following HTML:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="ISO-8859-1"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;input id="t1" type="text"&gt;
  
  &lt;script type="text/javascript"&gt;
  
  function myfunction() {
      var no=document.getElementById("t1").value;
  
      if(no==""||isNaN(no))
      {
          alert("Not Numeric");
      }
      else {
          for ( var int = 0; int &lt; no; int++) {
              for ( var int2 = 0; int2 &lt;=int; int2++) {
                  document.write("*");
              }
              document.write("&lt;br&gt;");
          }
      }
  }
  
  &lt;/script&gt;
  
  &lt;button type="button" onclick="myfunction()" &gt;click me&lt;/button&gt; 
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The above code is showing output like this after entering the value: 5</p>
  
  <pre><code>*
  **
  ***
  ****
  *****
  </code></pre>
  
  <p>But I am not getting the above output after I modified as below:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="ISO-8859-1"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;input id="t1" type="text"&gt;
  
  &lt;script&gt;
  
  function myfunction() {
      var no=document.getElementById("t1").value;
  
      if(no==""||isNaN(no))
      {
          alert("Not Numeric");
      }
      else {
          for ( var int = 0; int &lt; no; int++) {
              for ( var int2 = 0; int2 &lt;=int; int2++) {
                  document.getElementById("demo").innerHTML="*";
              }
              document.getElementById("demo").innerHTML="&lt;br&gt;";
          }
      }
  }
  
  &lt;/script&gt;
  
  
  &lt;button type="button" onclick="myfunction()" &gt;click me&lt;/button&gt;
  
  &lt;p id="demo"&gt;A Paragraph.&lt;/p&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I just want the above output using inner html so that while showing output it will not display in another or new html page.</p>