This code counts the number of rows existing then add new row with 3 textbox
after the last row. Each textbox have their own unique name
<script language="javascript">
function addRow(){
var newRow =
document.getElementById("mytable").insertRow(document.getElementById("mytable").
rows.length);
var num = ((document.getElementById("mytable").rows.length - 1) * 3) - 1;
//add 3 cells (<td>) to the new row and set the innerHTML to contain text boxes
var oCell = newRow.insertCell(0);
oCell.height = '25';
oCell.vAlign = 'middle';
oCell.align = 'center';
oCell.style.background = '#EEEEEE';
oCell.innerHTML = "<input type='text' name='textfield"+(num)+"'
class='bodytext' size='20' align='center'>";
oCell = newRow.insertCell(1);
oCell.height = '25';
oCell.vAlign = 'middle';
oCell.align = 'center';
oCell.style.background = '#EEEEEE';
oCell.innerHTML = "<input type='text' name='textfield"+(num + 1)+"'
class='bodytext' size='35' align='center'>";
oCell = newRow.insertCell(2);
oCell.height = '25';
oCell.vAlign = 'middle';
oCell.align = 'center';
oCell.style.background = '#EEEEEE';
oCell.innerHTML = "<input type='text' name='textfield"+(num + 2)+"'
class='bodytext' size='3' align='center'>";
}
</script>
|