Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Show/Hide Table Rows

Reply
Thread Tools

Show/Hide Table Rows

 
 
shankwheat
Guest
Posts: n/a
 
      04-06-2006
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>

 
Reply With Quote
 
 
 
 
RobG
Guest
Posts: n/a
 
      04-07-2006
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving dynamically created table rows up and down in an HTML table T.G. Javascript 2 10-14-2008 12:56 PM
table.rows vs. table.getElementsByTagName (+ a regex question) eBob.com Javascript 5 05-20-2008 10:58 AM
script for moving rows up and down and traverse thru rows of HTML table Subba Rao via DotNetMonster.com ASP .Net 0 03-19-2005 06:46 AM
Table/table rows/table data tag question? Rio HTML 4 11-05-2004 08:11 AM
Help ASP; get last inserted value from one table, insert multiple rows in another table. PT ASP General 1 10-07-2004 07:27 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57