Hiding multiple rows in a dynamic table

R

Rick Measham

I have a set of data that I display in a table. Each row has a category
and there may be a dozen or more rows in the same category. I'm looking
to add filter buttons to the page to hide/show categories on the fly.

Currently I can: Set the id on the tr to (category name) or to (category
name.data id).

Using the first, is there a way to hide all rows with that same id? It
seems currently to only hide the first row with that id.

If not, is there an easy way to find all rows whose id starts with
(category name)? I figure I could regex over every element in the page
looking for ones that begin with a particular id, but that would be
silly.

Also, is there a way to refer to every row of a table? I'd like to first
hide every row, then show those in the required category.
 
M

Martin Honnen

Rick said:
I have a set of data that I display in a table. Each row has a category
and there may be a dozen or more rows in the same category. I'm looking
to add filter buttons to the page to hide/show categories on the fly.

Currently I can: Set the id on the tr to (category name) or to (category
name.data id).

Using the first, is there a way to hide all rows with that same id? It
seems currently to only hide the first row with that id.

If not, is there an easy way to find all rows whose id starts with
(category name)? I figure I could regex over every element in the page
looking for ones that begin with a particular id, but that would be
silly.

Also, is there a way to refer to every row of a table? I'd like to first
hide every row, then show those in the required category.

If you have
<table id="tableId"
you can access the rows collection of the table element object:
var table;
if (document.all)
table = document.all['tableId'];
else if (document.getElementById)
table = document.getElementById('tableId');
if (table) {
//access table.rows
}
 

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

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top