Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

Hide/Show Table Rows

 
 
evanburen@gmail.com
Guest
Posts: n/a
 
      02-10-2006
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();"/>

 
Reply With Quote
 
 
 
 
John
Guest
Posts: n/a
 
      02-11-2006

<> wrote in message
news: oups.com...
> 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]);
> }
> }
> }



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);
}



 
Reply With Quote
 
 
 
 
Danny
Guest
Posts: n/a
 
      02-11-2006


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
 
Reply With Quote
 
evanburen@gmail.com
Guest
Posts: n/a
 
      02-11-2006
Perfect! Thanks.

 
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