I have a table that is a basic form with name address , etc. But it is possible for the person to have more than one address so I have a button that will duplicate all of the address information. Unfortunately I can't figure out how to duplicate the information but change the name of the input field.
So far I have:
function insertTableRow(id)
{
var table = document.getElementById(id);
// insert the new row
var newRow = table.insertRow();
rowHtml = table.rows(2).outerHTML;
rowAtr = rowHtml.split('>')[0].split(' ')
for(i=1;i<rowAtr.length;i++) {
rowAttribute = rowAtr.split('=')[0];
newRow.setAttribute(rowAttribute,table.rows(2).getAttribute(rowAttribute))
}
alert(newRow.outerHTML)
for (c=0; c<2; c++)
{
newCell = newRow.insertCell();
newCell.innerHTML = table.rows(2).cells(c).innerHTML;
}
}
Now say my last row in the table is:
<tr><td><input name="name"></td></tr>
How do I duplicate the row BUT change the input name to name="name2"??????
Any help is greatly appreciated. Education is what you get from reading the small print.
Experience is what you get from not reading it.
So far I have:
function insertTableRow(id)
{
var table = document.getElementById(id);
// insert the new row
var newRow = table.insertRow();
rowHtml = table.rows(2).outerHTML;
rowAtr = rowHtml.split('>')[0].split(' ')
for(i=1;i<rowAtr.length;i++) {
rowAttribute = rowAtr.split('=')[0];
newRow.setAttribute(rowAttribute,table.rows(2).getAttribute(rowAttribute))
}
alert(newRow.outerHTML)
for (c=0; c<2; c++)
{
newCell = newRow.insertCell();
newCell.innerHTML = table.rows(2).cells(c).innerHTML;
}
}
Now say my last row in the table is:
<tr><td><input name="name"></td></tr>
How do I duplicate the row BUT change the input name to name="name2"??????
Any help is greatly appreciated. Education is what you get from reading the small print.
Experience is what you get from not reading it.