Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

showing/hiding divs ... adding to an object name

I have a couple of div tags, and I need to show or hide some of them, the problem is, I need to hide or show several at once, but the all have a "groupname"

say, one divs are bla1, bla2 and bla3.
I want to sent [b]bla[/b] to the function, like
showhide(bla)
and then it does something to bla1, 2 and 3
I tried the code below, but instead of the object [bla1]
I get [bla]1 ... and that doesn't exist :-(
any ideas ?

function showhide(myvar) {
[b] oink=(myvar + '1');
show=(myvar + '2');
hide=(myvar + '3');[/b]
if (oink.style.display == "none") {
oink.style.display = "";
show.style.display = "none";
hide.style.display = ""
} else {
oink.style.display = "none";
show.style.display = "";
hide.style.display = "none"
}
}

Comments



  • you'll have to combine the strings with each other.
    try this:

    text="blanumb";
    re=/numb/gi;
    showhide(text);

    function showhide(myvar){
    oink=myvar.replace(re, "1");
    show=myvar.replace(re,"2");
    hide=myvar.replace(re,"3");

    oink.style.display = "none";
    show.style.display = "";
    hide.style.display = "none"
    }

    I hope it works...

    URL:http://www.uaweiss.de

Sign In or Register to comment.