Click to See Complete Forum and Search --> : accessing html of table row


AtomicPenguin
01-11-2003, 01:28 AM
Hey y'all!

Does anyone know a way of referring to the html of an entire table row - from the opening <tr> to the closing </tr> ?

I'm wrote a script using Microsoft's innerHTML function that can do this, but I'm looking for a cross-browser DOM solution instead.

Any takers...? :)

swon
01-11-2003, 05:02 AM
how do you use the microsoft specificated:

document.YourElement.rows[rowsnumber].innerHTML ?

AtomicPenguin
01-11-2003, 01:47 PM
Kinda like this:

<table>
<tr><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td></tr>
<tr id="chicken"><td>contents here.<img src="./example.gif"></td></tr>
<tr><td>&nbsp;</td></tr>
</table>

<input type="button" onclick="javascript: alert(document.all['chicken'].innerHTML);">



- I stuck the <img> tag in the row's <td> just to show how innerHTML returns the HTML, not just the text.

swon
01-11-2003, 05:34 PM
Okay, the DOM version is:


document.getElementById("chicken").innerHTML

AtomicPenguin
01-11-2003, 07:27 PM
Hey, thanks Swon!

Mind if I ask another one? I have this code which works fine in IE, but not in Mozilla or Netscape 6.

var tableElement = document.getElementById("t");

if (tableElement.rows(row).cells(0).firstChild.getAttribute ("checked") == true) {
alert("checked");
}


I'm having trouble identifying precisely which spot the other browsers don't like.

All it's doing is checking to see if the relevant input=checkbox element is checked or not.

Sorry if these questions are rudimentary. :)

swon
01-11-2003, 08:31 PM
Are you using forms? It might be the best when you get the checked boxes via the form object.
Post an example of your code.