Forum Moderators: open

Message Too Old, No Replies

Table rows collection help

         

trevordixon

7:49 pm on Jun 19, 2006 (gmt 0)

10+ Year Member



This works in Firefox, but not in IE.


for (var i in appraisertable.rows) {
var row = appraisertable.rows[i];
alert(row.id);
}

IE displays "undefined" and gives the error "id is null or not an object." Like I said before, Firefox works great. What's my problem here?

AWildman

3:35 pm on Jun 27, 2006 (gmt 0)

10+ Year Member



I got IE to show row ids, but I also go some undefineds in the alerts as well. Here's my code:

<table id = "craps">
<tr id = "row1"><td>some text</td></tr>
<tr id = "row2"><td>some more text</td></tr>
</table>
<a href = "javascript:alertRowId()">click me</a>

function alertRowId()
{
var crapsTable = document.getElementById("craps");

for (var i in crapsTable.rows)
{
var row = crapsTable.rows[i];
alert(row.id);
}
}

I don't understand why I got some undefineds, but I did get "row1" and "row2" to show.