Connecting Tech Pros Worldwide Help | Site Map

Hide/Show Table Rows

 
LinkBack Thread Tools Search this Thread
  #1  
Old February 10th, 2006, 10:15 PM
evanburen@gmail.com
Guest
 
Posts: n/a
Default Hide/Show Table Rows

I'm using this to hide rows in a table created from ASP. This works
well but I would like to also be able to 'Show' the records again that
there hidden by removeEvents( ). Thanks.

function removeEvents( ) {
var elem = document.getElementById("EventsBody");
for (var i = elem.rows.length-1; i >= 0 ; i--) {
if (elem.rows[i].cells[0].firstChild.checked) {
elem.removeChild(elem.rows[i]);
}
}
}


<% Do While Not rs.EOF %>
<tr>
<td><input type="checkbox"/></td>
</tr>
<%
rs.MoveNext
Loop
%>

<input type="button" value="Hide Checked Events"
onclick="removeEvents();"/>


  #2  
Old February 11th, 2006, 12:05 AM
John
Guest
 
Posts: n/a
Default Re: Hide/Show Table Rows


<evanburen@gmail.com> wrote in message
news:1139612878.007608.160840@z14g2000cwz.googlegr oups.com...[color=blue]
> I'm using this to hide rows in a table created from ASP. This works
> well but I would like to also be able to 'Show' the records again that
> there hidden by removeEvents( ). Thanks.
>
> function removeEvents( ) {
> var elem = document.getElementById("EventsBody");
> for (var i = elem.rows.length-1; i >= 0 ; i--) {
> if (elem.rows[i].cells[0].firstChild.checked) {
> elem.removeChild(elem.rows[i]);
> }
> }
> }[/color]


How about this?

function displayEvents( show) {
var elem = document.getElementById("EventsBody");
for (var i = elem.rows.length-1; i >= 0 ; i--) {
if (elem.rows[i].cells[0].firstChild.checked) {
elem.rows[i].style.display = show ? "inline" : "none";
}
}
}


function hideEvents( ) {
displayEvents(false);
}

function showEvents( ) {
displayEvents(true);
}



  #3  
Old February 11th, 2006, 01:45 AM
Danny
Guest
 
Posts: n/a
Default Re: Hide/Show Table Rows



Do not use .removeChild() method, as it nulls out the node, instead,
just set the .style.display='none' and then back to 'table-row' for
when you want to show them :).

Danny
  #4  
Old February 11th, 2006, 03:25 AM
evanburen@gmail.com
Guest
 
Posts: n/a
Default Re: Hide/Show Table Rows

Perfect! Thanks.

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.