Hide/Show Table Rows

Discussion in 'Javascript' started by evanburen@gmail.com, Feb 10, 2006.

  1. Guest

    I'm using this to hide rows in a table created from ASP. This works
    well but I would like to also be able to 'Show' the records again that
    there hidden by removeEvents( ). Thanks.

    function removeEvents( ) {
    var elem = document.getElementById("EventsBody");
    for (var i = elem.rows.length-1; i >= 0 ; i--) {
    if (elem.rows.cells[0].firstChild.checked) {
    elem.removeChild(elem.rows);
    }
    }
    }


    <% Do While Not rs.EOF %>
    <tr>
    <td><input type="checkbox"/></td>
    </tr>
    <%
    rs.MoveNext
    Loop
    %>

    <input type="button" value="Hide Checked Events"
    onclick="removeEvents();"/>
     
    , Feb 10, 2006
    #1
    1. Advertising

  2. John Guest

    <> wrote in message
    news:...
    > I'm using this to hide rows in a table created from ASP. This works
    > well but I would like to also be able to 'Show' the records again that
    > there hidden by removeEvents( ). Thanks.
    >
    > function removeEvents( ) {
    > var elem = document.getElementById("EventsBody");
    > for (var i = elem.rows.length-1; i >= 0 ; i--) {
    > if (elem.rows.cells[0].firstChild.checked) {
    > elem.removeChild(elem.rows);
    > }
    > }
    > }



    How about this?

    function displayEvents( show) {
    var elem = document.getElementById("EventsBody");
    for (var i = elem.rows.length-1; i >= 0 ; i--) {
    if (elem.rows.cells[0].firstChild.checked) {
    elem.rows.style.display = show ? "inline" : "none";
    }
    }
    }


    function hideEvents( ) {
    displayEvents(false);
    }

    function showEvents( ) {
    displayEvents(true);
    }
     
    John, Feb 11, 2006
    #2
    1. Advertising

  3. Danny Guest

    Do not use .removeChild() method, as it nulls out the node, instead,
    just set the .style.display='none' and then back to 'table-row' for
    when you want to show them :).

    Danny
     
    Danny, Feb 11, 2006
    #3
  4. Guest

    Perfect! Thanks.
     
    , Feb 11, 2006
    #4
    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. RA
    Replies:
    1
    Views:
    3,996
  2. JDP@Work

    Show Hide Table(s), Rows & Cells w/out a postback

    JDP@Work, Apr 20, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    210
    JDP@Work
    Apr 20, 2006
  3. Harry

    Dynamically Show/Hide table rows?

    Harry, Sep 3, 2003, in forum: Javascript
    Replies:
    3
    Views:
    401
    Vjekoslav Begovic
    Sep 3, 2003
  4. KathyB
    Replies:
    2
    Views:
    160
    Kathy Burke
    Sep 29, 2003
  5. Mark

    Show / Hide Table Rows

    Mark, Oct 20, 2003, in forum: Javascript
    Replies:
    2
    Views:
    189
    Louise Woodward
    Oct 23, 2003
Loading...

Share This Page