Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Table within Table not responding to ElementById call

Thread Tools

Table within Table not responding to ElementById call

Posts: n/a
I have a table created with Javascript. When any row after the first
row is clicked on, that row expands and shows a smaller table inside of

/////////Code Start//////////

/* rownum is the number of the row of the table that was clicked on.
Since row 0 contains the headings of the table, but the array of
objects starts at 0, when calling on the object array, rownum is sent
minus 1. */
var rownum = this.rowIndex;

var stuff;

/* thisTableId is the id of the outer table that was clicked on */
var x = document.getElementById('thisTableId').rows[rownum].cells;

tableArray[rownum-1].image = '<img src="dashSign.gif"><\/img>';
x[0].innerHTML = tableArray[rownum-1].image;

/* variable stuff will hold the smaller table's information until added
to the cell of the row */
stuff = '<b>' + tableArray[rownum-1].name + '<\/b><BR><BR>';
var nameId = "newTable";

/* making the first part of the inner table */
stuff += '<TABLE border=1 width=100% cellSpacing=0 cellPadding=10
id="'+nameId +'">';

for (var h = 0; h < statsArray[rownum-1][2]; h++)
/* setRow contains the code for each row to be added */
stuff += regionsArray[rownum-1][h].setRow;
stuff+= '<\/TABLE>';

/* after all that, add the new table to the cell. */
/* the new table shows up on screen inside of the larger table at this
point */

/* this alert shows that the new table seems to have the correct id and
all the rest of the code. */

/**** BUT from here on, the table cannot seem to be retrieved. This
code returns null or undefined when tested ****/
var table = document.getElementById(nameId);
rows = table.rows;
var n = rows.length;

/////////Code Finished//////////

note that I am only interested in IE for this project. It does not
need to be platform compatible.

If someone could help me, it would be great. I don't understand why
the new table that was created, cannot be reached.

Thanks, Camet

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Responding to LinkButton within a Gridview CJM ASP .Net 2 07-06-2007 04:01 PM
Responding to LinkButton within a Gridview CJM ASP .Net Web Controls 2 07-06-2007 04:01 PM
Grab ElementbyID from innerhtml Javascript 6 06-30-2006 08:25 PM
table not responding in IE Jeff Fritz HTML 9 10-21-2005 04:19 PM
Not able to veiw images and if tried EXPLORER NOT RESPONDING Jeff Computer Support 2 02-29-2004 07:00 PM