function addRowNew( varTable, varRow ) { i = i + 1; // Get a previous row and copy it's content var curRow = document.getElementById( varRow ); curRow = curRow.innerHTML; alert( curRow ); curRow = curRow.replace( /name="subject[0-9]+"/, 'name="subject' + (i+1) + '"' ); curRow = curRow.replace( /name="quali[0-9]+"/, 'name="quali' + (i+1) + '"' ); curRow = curRow.replace( /value="[A-Za-z0-9]*"/, '' ); curRow = curRow.replace( /value="[A-Za-z0-9]*"/, '' ); // Count how many rows are in the table atm, var numRows = document.getElementById( varTable ).rows; num = numRows.length; // Now Add new row to the table var newRow = document.getElementById( varTable).insertRow( num ); newRow.innerHTML = curRow; }