Show/Hide Table Rows

Discussion in 'Javascript' started by shankwheat, Apr 6, 2006.

  1. shankwheat

    shankwheat Guest

    I'm creating a dynamic table with asp and I would like to add a "Show
    All" and "Collapse All" feature to show/hide certain rows within the
    table. This code works well for showing/hiding one row at a time but
    I'm not sure how to all the "Show All/Hide All" feature. Thanks.

    function sh_RowShowHide(sh_RowID) {
    var currRow = document.getElementById(sh_RowID);
    if (currRow.style.display=="none") {
    currRow.style.display="";
    document.getElementById(sh_RowID+"img").src = sh_HideImg;
    } else {
    currRow.style.display="none";
    document.getElementById(sh_RowID+"img").src = sh_ShowImg;
    }
    }


    <table>
    <tbody id="EventsBody">
    <tr>
    <td></td>
    <td>Event Date</td>
    <td>Event</td>
    </tr>

    <% Do While Not rs_Events.EOF %>
    <tr>
    <td><img border="0" id="<%=rs_Events("EventID")%>img"
    style="clear:both;"
    onclick="sh_RowShowHide('<%=rs_Events("EventID")%>',0); return false;"
    src="directory_minus.gif" /></td>
    <td><%=rs_Events("EventDate")%></td>
    <td><%=rs_Events("UpdateDescription")%></td>

    </tr>
    <tr id="<%=rs_Events("EventID")%>" style="display:inline;">
    <td colspan="3"><%=rs_Events("EventDescription")%></td>
    </tr>

    <%
    rs_Events.MoveNext
    Loop
    %>

    </tbody>
    </table>
    shankwheat, Apr 6, 2006
    #1
    1. Advertising

  2. shankwheat

    RobG Guest

    shankwheat wrote:
    > I'm creating a dynamic table with asp and I would like to add a "Show
    > All" and "Collapse All" feature to show/hide certain rows within the
    > table. This code works well for showing/hiding one row at a time but
    > I'm not sure how to all the "Show All/Hide All" feature. Thanks.


    function toggleAll(tbody_ID)
    {
    var tBody, tStyle;
    if ( document.getElementById
    && (tBody = document.getElementById(tbody_ID))
    && (tStyle = tBody.style)) {
    tStyle.display = ('none' == tStyle.display)? '' : 'none';
    }
    }


    [...]


    --
    Rob
    RobG, Apr 7, 2006
    #2
    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,959
  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:
    201
    JDP@Work
    Apr 20, 2006
  3. Harry

    Dynamically Show/Hide table rows?

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

    Show / Hide Table Rows

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

Share This Page