469,352 Members | 1,661 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

Show/Hide Table Rows

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>

Apr 6 '06 #1
1 1662
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
Apr 7 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Harry | last post: by
2 posts views Thread by Mark | last post: by
20 posts views Thread by WindAndWaves | last post: by
10 posts views Thread by oLE | last post: by
2 posts views Thread by Mateo | last post: by
3 posts views Thread by evanburen | last post: by
11 posts views Thread by jimstruckster | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.