Why can't I add a new row in my table using javascript?
<pre><code>function add(tableID) {
    var table = document.getElementById(tableID);

    var rowCount = table.rows.length;
    var row = table.insertRow(rowCount);

    var cell1 = row.insertCell(0);
    cell2.innerHTML = rowCount;

    var cell2 = row.insertCell(1);
    var element1 = document.createElement("input");
    element1.type = "text";
    cell2.appendChild(element1);   
}
</code></pre>

<p><a href="http://jsfiddle.net/89Q7T/" rel="nofollow">jsFiddle: add a row</a></p>

<p>What is wrong with my code? It doesn't seem to work.</p>

<p>Any help will be greatly appreciated.</p>
