By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,846 Members | 1,211 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,846 IT Pros & Developers. It's quick & easy.

Show/Hide Table Rows

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.