Show/Hide Table Rows

S

shankwheat

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>
 
R

RobG

shankwheat said:
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';
}
}


[...]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top