Hi, I'm looking for information on whether it's possible to add a row in the middle of a table. Ex. my Table contains 2 <tr>s, add a <tr> between the original two. The cide below just appends to the table but I haven't found how to insert after the indicated row...
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<script language="javascript">
function addRow(thisObj)
{
var theTable = thisObj.parentNode.parentNode;
var theTBody = thisObj.parentNode;
var theCell_1;
var theCell_2;
var theCell_3;
var rowAdd = document.createElement('tr');
// alert('table contents = ' + theTable.innerHTML + '\n\nbody contents = ' + theTBody.innerHTML + '\n\nrow contents = ' + thisObj.innerHTML);
theCell_1 = document.createElement('td');
theCell_1.innerHTML = 'empty';
theCell_2 = document.createElement('td');
theCell_2.innerHTML = 'test';
theCell_3 = document.createElement('td');
theCell_3.innerHTML = 'again';
rowAdd.id = thisObj.id + '_1';
theTBody.appendChild(rowAdd);
rowAdd.appendChild(theCell_1);
rowAdd.appendChild(theCell_2);
rowAdd.appendChild(theCell_3);
}
</script>
<body>
<table cellspacing="2" cellpadding="2" border="1">
<tr id="r1">
<td><input type="checkbox"></td><td>qwert</td><td>werty</td>
</tr>
<tr id="r2">
<td><input type="checkbox"></td><td>asdfg</td><td>sdfgh</td>
</tr>
</table>
<button onclick="addRow(document.all.r1)">add</button>
</body>
</html>
[\code]
Any help is appreciated
-----------------------------------
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rich Cook