Show / Hide Table Rows

Discussion in 'Javascript' started by Mark, Oct 20, 2003.

  1. Mark

    Mark Guest

    Hi,

    I need to be able to have five different links and when when someone
    clicks to show row 2, row 1 automatically hides. Right now all i can
    figure out is a link that will show but then you have to click the
    same link to hide. I want to be able to turn off a row when another
    row is clicked on to show?

    Can someone help?

    THanks
    Mark
    Mark, Oct 20, 2003
    #1
    1. Advertising

  2. Mark

    kaeli Guest

    In article <>,
    enlightened us with...
    > Hi,
    >
    > I need to be able to have five different links and when when someone
    > clicks to show row 2, row 1 automatically hides. Right now all i can
    > figure out is a link that will show but then you have to click the
    > same link to hide. I want to be able to turn off a row when another
    > row is clicked on to show?
    >


    Put code to hide all non-hidden rows in the onclick that shows one row.

    If you id'd your rows right (that is, easy to loop through by calling
    them all the same with one char difference or such), this can be done in
    a simple loop.

    Say all your rows were "myRow_" and a number.

    <tr id="myRow_1" onClick="doIt(this)">
    doIt would show the row and loop through and hide the other rows. Say
    you have 1-10 of them.

    function doIt(r)
    {
    if (! document.getElementById)
    {
    alert("error");
    return;
    }
    for (x=1; x<=10; x++)
    {
    e = document.getElementById("myRow_"+x);
    if (!e.style)
    {
    alert("error");
    break;
    }
    if (e == r) e.style.visibility = "visible";
    else e.style.visibility = "hidden";
    }
    }

    I'm tired and I didn't test this. Works in theory. Typos be darned. :)

    -------------------------------------------------
    ~kaeli~
    Jesus saves, Allah protects, and Cthulhu
    thinks you'd make a nice sandwich.
    http://www.ipwebdesign.net/wildAtHeart
    http://www.ipwebdesign.net/kaelisSpace
    -------------------------------------------------
    kaeli, Oct 20, 2003
    #2
    1. Advertising

  3. Can you hide comboboxs using the style.display = "none"

    "kaeli" <> wrote in message
    news:...
    > In article <>,
    > enlightened us with...
    > > Hi,
    > >
    > > I need to be able to have five different links and when when someone
    > > clicks to show row 2, row 1 automatically hides. Right now all i can
    > > figure out is a link that will show but then you have to click the
    > > same link to hide. I want to be able to turn off a row when another
    > > row is clicked on to show?
    > >

    >
    > Put code to hide all non-hidden rows in the onclick that shows one row.
    >
    > If you id'd your rows right (that is, easy to loop through by calling
    > them all the same with one char difference or such), this can be done in
    > a simple loop.
    >
    > Say all your rows were "myRow_" and a number.
    >
    > <tr id="myRow_1" onClick="doIt(this)">
    > doIt would show the row and loop through and hide the other rows. Say
    > you have 1-10 of them.
    >
    > function doIt(r)
    > {
    > if (! document.getElementById)
    > {
    > alert("error");
    > return;
    > }
    > for (x=1; x<=10; x++)
    > {
    > e = document.getElementById("myRow_"+x);
    > if (!e.style)
    > {
    > alert("error");
    > break;
    > }
    > if (e == r) e.style.visibility = "visible";
    > else e.style.visibility = "hidden";
    > }
    > }
    >
    > I'm tired and I didn't test this. Works in theory. Typos be darned. :)
    >
    > -------------------------------------------------
    > ~kaeli~
    > Jesus saves, Allah protects, and Cthulhu
    > thinks you'd make a nice sandwich.
    > http://www.ipwebdesign.net/wildAtHeart
    > http://www.ipwebdesign.net/kaelisSpace
    > -------------------------------------------------
    Louise Woodward, Oct 23, 2003
    #3
    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. RA
    Replies:
    1
    Views:
    3,945
  2. JDP@Work

    Show Hide Table(s), Rows & Cells w/out a postback

    JDP@Work, Apr 20, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    196
    JDP@Work
    Apr 20, 2006
  3. Harry

    Dynamically Show/Hide table rows?

    Harry, Sep 3, 2003, in forum: Javascript
    Replies:
    3
    Views:
    380
    Vjekoslav Begovic
    Sep 3, 2003
  4. KathyB
    Replies:
    2
    Views:
    142
    Kathy Burke
    Sep 29, 2003
  5. Hide/Show Table Rows

    , Feb 10, 2006, in forum: Javascript
    Replies:
    3
    Views:
    210
Loading...

Share This Page