Hiding multiple rows in a dynamic table

Discussion in 'Javascript' started by Rick Measham, Sep 23, 2003.

  1. Rick Measham

    Rick Measham Guest

    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.

    --
    Change the *eye* in my email to the letter 'i'.
     
    Rick Measham, Sep 23, 2003
    #1
    1. Advertising

  2. Rick Measham wrote:

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

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Sep 23, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MattB

    hiding table rows by id?

    MattB, Mar 9, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    12,551
    MattB
    Mar 9, 2005
  2. luna

    Hiding table rows .asp

    luna, Jan 17, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    473
  3. Garg
    Replies:
    2
    Views:
    1,407
    Eliyahu Goldin
    Feb 15, 2007
  4. chris f

    Hiding rows in an ASP.NET table

    chris f, Jun 11, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    1,842
    Munna
    Jun 11, 2008
  5. F. Da Costa

    Hiding rows in a table via <div>

    F. Da Costa, Dec 3, 2003, in forum: Javascript
    Replies:
    8
    Views:
    244
    F. Da Costa
    Dec 5, 2003
Loading...

Share This Page