> "Giggle Girl" <mi*******@gmail.com> wrote:
news:11*********************@g14g2000cwa.googlegro ups.com....
Google gave me many hits for ""HTMLTableElement insertRow", but no
practical examples.
Can someone give me the code to insert some _CONTENT_ into a specifc
row of a table?
Specifically, how could I insert this simple row into the third
spot in a table (that has a tbody already), WITHOUT using innerHTML?
<tr id="tree_row_3">
<td width="20" height="20"> </td>
<td width="20" height="20"> </td>
<td width="20" height="20">Cell 3</td>
<td colspan="7">Cell 4, with colspan!</td>
</tr>
Thanks to anyone who can help me with this,
Ann
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript">
var parent,clone,ckb;
function bink(x){
if(document.cloneNode && document.insertBefore){
parent = x.parentNode;
while(parent.tagName.toLowerCase()!='tr'){parent=p arent.parentNode;}
clone=parent.cloneNode(true);
ckb=(x.innerText)?x.innerText.replace(/\s+/g,' ').replace(/^\s+||\s+$/g,''):
x.textContent.replace(/\s+/g,' ').replace(/^\s+||\s+$/g,'');
}
switch (ckb) {
case 'Insert Before':
parent.parentNode.insertBefore(clone,parent);
break;
case 'Insert After':
parent.parentNode.insertBefore(clone,parent.nextSi bling);
break;
case 'Remove':
parent.parentNode.removeChild(parent);
break;
default:
alert('oh crap!');
}
}
</script>
<title></title>
<meta http-equiv="content-type" content=
"text/html; charset=windows-1252">
</head>
<body>
<table summary="" cellpadding="0" cellspacing="0" border="1">
<tr>
<td>Table Cell</td>
<td nowrap>
<button type="button" onclick="bink(this);">Insert Before</button>
<button type="button" onclick="bink(this);">Insert After</button>
<button type="button" onclick="bink(this);">Remove</button>
</td>
</tr>
<tr>
<td>Table Cell</td>
<td nowrap>
<button type="button" onclick="bink(this);">Insert Before</button>
<button type="button" onclick="bink(this);">Insert After</button>
<button type="button" onclick="bink(this);">Remove</button>
</td>
</tr>
</table>
</body>
</html>
--
BootNic Tuesday, February 07, 2006 1:42 PM
"Do not trust your memory; it is a net full of holes; the most
beautiful prizes slip through it."
*Georges Duhamel, The Heart's Domain*