title: Javascript: Add New Row To Table, skip th elements
body: <p>Awhile back, I found the following javascript function that allows you to dynamically add a row to a table:</p>
  
  <pre><code>function addRow(tableID) {
  
          var table = document.getElementById(tableID);
  
          var rowCount = table.rows.length;
          var row = table.insertRow(rowCount);
  
          var colCount = table.rows[0].cells.length;
  
          for(var i=0; i&lt;colCount; i++) {
  
              var newcell = row.insertCell(i);
  
              newcell.innerHTML = table.rows[0].cells[i].innerHTML;
              //alert(newcell.childNodes);
              switch(newcell.childNodes[0].type) {
                  case "text":
                          newcell.childNodes[0].value = "";
                          break;
                  case "checkbox":
                          newcell.childNodes[0].checked = false;
                          break;
                  case "select-one":
                          newcell.childNodes[0].selectedIndex = 0;
                          break;
              }
          }
      }
  </code></pre>
  
  <p>Does anyone, that actually has javascript experience (cause I have almost none) that could write a fix that will skip over the <code>&lt;th&gt;</code> tags?</p>
  
  <p>Here's the part of the table I don't want to be affected:</p>
  
  <pre><code>&lt;table id="scheduler"&gt;
    &lt;tr&gt;
      &lt;th scope="col"&gt;Engineer&lt;/th&gt;
      &lt;th scope="col"&gt;Monday&lt;/th&gt;
      &lt;th scope="col"&gt;Tuesday&lt;/th&gt;
      &lt;th scope="col"&gt;Wednesday&lt;/th&gt;
      &lt;th scope="col"&gt;Thursday&lt;/th&gt;
      &lt;th scope="col"&gt;Friday&lt;/th&gt;
      &lt;th scope="col"&gt;Saturday&lt;/th&gt;
      &lt;th scope="col"&gt;Sunday&lt;/th&gt;
    &lt;/tr&gt;
  </code></pre>
  
  <p>My problem is that when I have the <code>&lt;th&gt;</code> tags in, the header row ends up being the row that gets "cloned", not the row that just has <code>&lt;td&gt;</code> tags in it.</p>