JavaScript add distinct rows to table -addRow function
<p>I have re-used a common addRow function, however my basic js skills limit me from making big changes to the code. </p>

<p>this elegant function works, however i would like to have all elements in the new row to have different names to the previous row. 
a friend proposed the use of 
var new_name = old_name.replace(rowCount, rowCount+1); by using a counter,</p>

<p>so in the example below to have the newly created row to have elements "username_2" and "email_2"</p>

<p>THANKS!</p>

<pre><code>&lt;INPUT TYPE="text" NAME="username_1"&gt; : name &lt;BR&gt;
&lt;INPUT TYPE="text" NAME="email_1"&gt; : email &lt;BR&gt;




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>
