Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > How to keep IE from removing rows 'spontaneously' from a table?

Reply
Thread Tools

How to keep IE from removing rows 'spontaneously' from a table?

 
 
F. Da Costa
Guest
Posts: n/a
 
      01-09-2004
Hi all,

I'm encountering some (for me) inexplicable IE behaviour re. the removal of
rows in a table. Exactly the same code works like a charm in Gecko browsers.

Here is the situation:
Frame set with two frames: jsLib & mainContent
*jsLib* contains global variables and a function (see below) that are
utilized during the session.
*mainContent* contains the pages the user looks at. They are
semi-dynamically created through the use of embedded js.
This js uses the global variables of the jsLib(-frame).

In the jsLib there is a variable called _statictable. It is responsible for
keeping track of the the 'state' of the table. I cannot do this in the
mainContent frame because the page get replaced by new (table modifying) pages.

The jsLib contains a function (see below) that modifies DOM elements that
are shown via the mainContent.

I have got the above structure working to satisfaction in Gecko.
Using IE5+ I can initialize _staticTable but as soon as I re-enter the
createTable for a second time (basically adding a new tbody) the
_staticTable does *not* contain any rows anymore and thus the whole
exercise becomes useless because I need to *add* the new tbody to *something*.

Gecko just keeps the variable _staticTable in place no worries but IE seems
to mess something up. I suppose the question is obvious.
What is the best way to keep track of (in memory) values in IE, to be used
and modified for the duration of the session?

TIA
Fermin DCG


var _staticTable;
var _tbodyRows;

/**
* This function is responsible for inserting a new tBody in an extisting
table.
* @param win = the window from where the function is called (mainContent)
* @param table = the ID of the table where th tbody needs to be inserted
*/
function createTbody(win, tBodyID) {
var windoc = win.document;
var myDiv = windoc.getElementById("doc");

// creates/ get an element of type TABLE
if (tBodyID=="" || !_staticTable) {
_staticTable = windoc.getElementById("treeTable");
return;
}
else {
var defaultTable = windoc.getElementById("treeTable");
myDiv.replaceChild(_staticTable, defaultTable);
}

// creates an element whose tag name is TBODY
var mytablebody = windoc.getElementById(tBodyID);
// creating all cells within the rows
for(var j=0, rLen=_tbodyRows.length; j<rLen; j++) {
// creates an element whose tag name is TR
var mycurrent_row=windoc.createElement("TR");

// start working on the columns
for(var i=0, cLen=_tbodyRows[0].length; i < cLen; i++) {
// creates an element whose tag name is TD
var mycurrent_cell=windoc.createElement("TD");
// creates a Text Node
var currenttext=windoc.createTextNode(_tbodyRows[j][i]);
// appends the Text Node we created into the cell TD
mycurrent_cell.appendChild(currenttext);
// appends the cell TD into the row TR
mycurrent_row.appendChild(mycurrent_cell);
}
// appends the row TR into TBODY
mytablebody.appendChild(mycurrent_row);
}
}
 
Reply With Quote
 
 
 
Reply

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
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Rows the rows of a grid view? Jason James ASP .Net 0 08-10-2006 09:24 PM
dynamically add new rows and save data typed in these rows to a database Arjen Hoekstra ASP .Net 0 08-02-2005 12:15 PM
convert rows to columns and columns to rows helpful sql ASP .Net 0 05-19-2005 06:03 PM
script for moving rows up and down and traverse thru rows of HTML table Subba Rao via DotNetMonster.com ASP .Net 0 03-19-2005 06:46 AM



Advertisments