Results 1 to 5 of 5

Thread: insertRow in Netscape 4.7

  1. #1

    Thread Starter
    Addicted Member MrPresident2k's Avatar
    Join Date
    May 2002
    Location
    INDIA
    Posts
    167

    insertRow in Netscape 4.7

    Hi,

    Iam trying to insert a row in html table dynamically in a click of a button. Iam using ther following code.

    Code:
    <HTML>
    <HEAD>
    <STYLE>
    .js {
      color: white;
      background-color: orange;
    }
    </STYLE>
    <SCRIPT>
    function addRowDOM (tableID) { 
    // pass every cell content as a futher arg
      var table = 
        document.all ? document.all[tableID] :
          document.getElementById(tableID);
      if (arguments.length > 1) {
        var row = table.insertRow(table.rows.length);
        if (document.all) {
          for (var i = 1; i < arguments.length; i++) {
            var cell = row.insertCell(i - 1);
            cell.innerHTML = arguments[i];
          }
        }
        else if (document.getElementById) { 
    //NN6 bug inserting cells in wrong sequence
          for (var i = arguments.length - 1; i >= 1; i--) {
            var cell = row.insertCell(arguments.length - 1 - i);
            cell.appendChild(document.createTextNode(arguments[i]));
          }
        }
      }
    }
    function addRowHTML (tableID, html) {
      if (document.getElementById && !document.all) {
        var table = document.getElementById(tableID);
        var tbody = table.tBodies[table.tBodies.length - 1];
        var range = document.createRange();
        range.setStartAfter(tbody.lastChild);
        var docFrag = range.createContextualFragment(html);
        tbody.appendChild(docFrag);
      }
    }
    </SCRIPT>
    </HEAD>
    <BODY>
    <BUTTON 
      ONCLICK="addRowDOM
    ('table1', 'JavaScript.FAQTs.com', 'www.FAQTs.com');"
    >
    add row per DOM methods
    </BUTTON>
    <BUTTON 
      ONCLICK="addRowHTML('table1', 
    '<TR><TD>JavaScript.FAQTs.com<\/TD><TD>www.FAQTs.com<\/TD><\/TR>');"
    >
    add row as html
    </BUTTON>
    <TABLE ID="table1" BORDER="1" CLASS="js">
    <TBODY>
    <TR>
    <TD>
    JavaScript.FAQTs.com
    </TD>
    <TD>
    www.FAQTs.com
    </TD>
    </TR>
    </TBODY>
    </TABLE>
    </BODY>
    </HTML>
    This works perfectly in IE5 and Netscape 6 and above.Is there any alternative method, so that I can get the same in Netscape 4.7?

    Thanks,
    Pres.

  2. #2
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    I doubt you'll get it to work in Netscape 4 as its DOM is quite limited. You could try referencing the table using document.tables instead?
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

  3. #3

    Thread Starter
    Addicted Member MrPresident2k's Avatar
    Join Date
    May 2002
    Location
    INDIA
    Posts
    167

    Pls Explain

    Hi,

    Can you please explain this on how document.tables can be used.

    Thanks,
    Pres

  4. #4
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    try replacing document.getElementById(tableId) with document.tables(tableId).

    document.tables is a collection of all the tables in the document.

    To be honest, I've never tried this is Netscape 4 but it may work.
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    NS4.x won't allow it. You could only make that region a layer and rewrite the whole html of it using document.write

    But who uses NS4 now anyway?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width