Hide/Show Table Rows

E

evanburen

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.cells[0].firstChild.checked) {
elem.removeChild(elem.rows);
}
}
}


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

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

John

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.cells[0].firstChild.checked) {
elem.removeChild(elem.rows);
}
}
}



How about this?

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


function hideEvents( ) {
displayEvents(false);
}

function showEvents( ) {
displayEvents(true);
}
 
D

Danny

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
 

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,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top