title: how to create dynamic row with input fields in html table from given row
body: <p>Im new for Html and javascript. I want to create dynamic row with input fields in table while click button,that number of row given from user. In my code, row created dynamically but its not append prevoius one. Its created freshly. But ,I want to append row if table already created.</p>
  
  <p>Here my code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function createTable() {
    var a;
  
    a = document.getElementById('tb1').value;
  
    if (a == "") {
      alert("Please enter some numeric value");
    } else {
      var rows = "&lt;th&gt;Item Name&lt;/th&gt;&lt;th&gt;Quantity&lt;/th&gt;&lt;th&gt;QuantityType&lt;/th&gt;&lt;th&gt;Amount&lt;/th&gt;";
      for (var i = 0; i &lt; a; i++) {
        rows += "&lt;tr&gt;&lt;td&gt;&lt;input type='text' name='" + "name".concat(i+1) + "'&gt;&lt;/td&gt;&lt;td&gt;&lt;input type='text' name='" + "quantity".concat(i+1) + "'&gt;&lt;/td&gt;&lt;td&gt;&lt;input type='text' name='" + "qtype".concat(i+1) + "'&gt;&lt;/td&gt;&lt;td id='amt'&gt;&lt;input type='text' id='sum' onkeyup='myfunction(this.value);' name='" + "total".concat(i+1) + "'&gt;&lt;/td&gt;&lt;/tr&gt;";
      }
  
      document.getElementById("table").innerHTML = rows;
    }
  }</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>div {
    background: red;
    margin: 5px;
  }
  
  table {
    border: 2px solid black;
  }
  
  td {
    padding: 10px;
    border: 1px solid lightgrey;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head lang="en"&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;title&gt;&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;input type="text" id="tb1"/&gt;
      &lt;button type="button" onclick='createTable()'&gt;Click Me!&lt;/button&gt;
      &lt;table id="table" class="order-table table"  name="table1" required&gt;
      &lt;/table&gt;
    &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Please anyone help!</p>
  
  <p>Thanks in advance..</p>