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

Discussion in 'Javascript' started by F. Da Costa, Jan 9, 2004.

  1. F. Da Costa

    F. Da Costa Guest

    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]);
    // 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);
    }
    }
     
    F. Da Costa, Jan 9, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Subba Rao via DotNetMonster.com

    script for moving rows up and down and traverse thru rows of HTML table

    Subba Rao via DotNetMonster.com, Mar 19, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    8,351
    Subba Rao via DotNetMonster.com
    Mar 19, 2005
  2. Rio
    Replies:
    4
    Views:
    1,250
  3. Cogito
    Replies:
    13
    Views:
    3,657
    Sid Ismail
    May 26, 2005
  4. Dev
    Replies:
    3
    Views:
    939
  5. hisan
    Replies:
    1
    Views:
    1,415
    Dan Stromberg
    Jun 25, 2012
Loading...

Share This Page