Michael Hill <hillmw@ram.lmtas.lmco.com> writes:
[color=blue]
> I am still having problems with the dom. blah ...
>
> I have a table like:
>
> <tbody id="list">
> <tr>
> <td>a</td> <td>b</td> <td>c</td> <td>d</td>
>
> </tr>
> </tbody>
>
> To get the values "a", "b", "c", and "d" I have this code:[/color]
....
Accessing a table's cells is easier using the rows and cells collections.
[color=blue]
> //look at each td cell value
> for( i=0; i<my_cell.childNodes.length; i++ )[/color]
You are running through the child nodes of the first cell, so you
should only encounter "a".
Try giving the table an id, and then:
---
var cells = document.getElementById("tableId").rows[0].cells;
for (var i=0; i<cells.length; i++) {
var cell = cells.item(i);
for (var chld = cell.firstChild;chld;chld=chld.nextSibiling) {
if (chld.nodeType == 3) { //text node
// something with nodeValue, e.g.,
alert(chld.nodeValue);
}
}
}
---
--
Lasse Reichstein Nielsen -
lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'