javascript cell selection.

Hi all
This may not be the right place to ask but I can’t get the following javascript to work on the Vera. I have hunted high and low but all the methods seem to fail.

var lastRowIndex = table.rows.length-1; var lastCellIndex = table.rows[lastRowIndex].cells.length-1; var lastCell = table.rows[lastRowIndex].cells[lastCellIndex];

The .cells.length returns 0 even though I have cells in the table, actual last RowIndex does work. Obviously there is other code associated with this e.g. table has been defined.

lastRowIndex does return the correct number of rows.
The lastCellIndex returns -1 (from length-1)

Thanks

John

When I get stuck in JavaScript I break out FireBug and set breakpoints. I wonder if the cells member is a proper Array or if it is just an Object? Only the former has a length property, IIRC.

I agree that FireBug is the best way to debug this. Based on this your javascript looks OK. Maybe the html is malformed?

I think fuzle’s explanation is correct :slight_smile:

Thanks for your help

John