title: Creating button in td using javascript
body: <p>I am trying to create a button in a table every time that the add button is clicked. I am having trouble with the button being displayed in the td. Im sure that it has to do with my JS. Any help would be appreciated.
  HTML:</p>
  
  <pre><code>                            &lt;button class="btn btn-primary pull-right" onclick="myCreateFunction()"&gt;
        Add new
      &lt;/button&gt;
                              &lt;table class="table table-striped" border="4" cellpadding="3" cellspacing="1" id="usertable"&gt;
                                  &lt;tr&gt;
                                      &lt;th&gt;First Name&lt;/th&gt;
                                      &lt;th&gt;Last Name&lt;/th&gt;
                                      &lt;th&gt;Title&lt;/th&gt;
                                      &lt;th&gt;Supervisor&lt;/th&gt;
                                      &lt;th&gt;Holiday&lt;/th&gt;
                                      &lt;th&gt;Edit&lt;/th&gt;
                                      &lt;th&gt;Delete&lt;/th&gt;
  
                                  &lt;/tr&gt;
                                  &lt;?php while ($rowemployeelist = mysql_fetch_array($employeelistresult)) { ?&gt;
  
                                  &lt;tr&gt;
                                      &lt;td&gt;
                                          &lt;?php echo $rowemployeelist["first_name"] ?&gt;
                                      &lt;/td&gt;
  
                                      &lt;td&gt;
                                          &lt;?php echo $rowemployeelist ["last_name"] ?&gt;
                                      &lt;/td&gt;
  
                                      &lt;td&gt;
                                          &lt;?php echo $rowemployeelist ["title"]?&gt;
                                      &lt;/td&gt;
                                      &lt;td&gt;
                                          &lt;?php echo $rowemployeelist ["supervisor"]?&gt;
                                      &lt;/td&gt;
                                      &lt;td&gt;
                                          &lt;?php echo $rowemployeelist ["holiday"]?&gt;
                                      &lt;/td&gt;
                                      &lt;td&gt;&lt;button class="editbtn"&gt;Edit&lt;/button&gt;&lt;/td&gt;
  
                                      &lt;td&gt;&lt;a href="delete.php?id=' . $row['id'] . '"&gt;Delete&lt;/a&gt;&lt;/td&gt;
  
                                  &lt;/tr&gt;
                                  &lt;?php } ?&gt;
                              &lt;/table&gt;
  </code></pre>
  
  <p>JS:</p>
  
  <pre><code>function myCreateFunction() {
      var table = document.getElementById("usertable");
      var row = table.insertRow(1);
      var cell1 = row.insertCell(0);
      var cell2 = row.insertCell(1);
      var cell3 = row.insertCell(2);
      var cell4 = row.insertCell(3);
      var cell5 = row.insertCell(4);
      var cell5 = row.insertCell(5);
      var cell6 = row.insertCell(6);
  
      cell1.innerHTML = "";
      cell2.innerHTML = "";
      cell3.innerHTML = "";
      cell4.innerHTML = "";
      var button = document.createElement("button")
      button. innerHTML = "Do Something";
      var td = document. getElementsByTagName("td")[0];
      td.appendChild(button);
  
  
  }
  </code></pre>