Please help with a hiding DIV problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chris Hughes

    #1

    Please help with a hiding DIV problem

    I have a routine that creates a page with 2 sets of tables with divs around
    them.

    Each div tag has a name.
    The first set of tags are as follows
    div id="T123" STYLE="display: none;">
    div id="T113" STYLE="display: none;">
    etc

    I want to hide only the divs that start with T as I have others on the page
    that I do not want to hide

    Can someone please tell me how to do this??

    Many Thanks

    Chris



  • steve stevo

    #2
    Re: Please help with a hiding DIV problem

    You will need to run a loop of all layers on the page,

    for each layer get the id and test to see if there is a T within the id
    (indexof)

    then test to see if the T is the start of id (indexof again)

    then if true hide the layer

    Hope this Helps

    Simon Christie

    "Chris Hughes" <chris_hughes4N OSPAM@hotmail.c om> wrote in message
    news:3f94fd5b$0 $122$65c69314@m ercury.nildram. net...[color=blue]
    > I have a routine that creates a page with 2 sets of tables with divs[/color]
    around[color=blue]
    > them.
    >
    > Each div tag has a name.
    > The first set of tags are as follows
    > div id="T123" STYLE="display: none;">
    > div id="T113" STYLE="display: none;">
    > etc
    >
    > I want to hide only the divs that start with T as I have others on the[/color]
    page[color=blue]
    > that I do not want to hide
    >
    > Can someone please tell me how to do this??
    >
    > Many Thanks
    >
    > Chris
    >
    >
    >[/color]


    Comment

    • Evertjan.

      #3
      Re: Please help with a hiding DIV problem

      Chris Hughes wrote on 21 okt 2003 in comp.lang.javas cript:
      [color=blue]
      > I have a routine that creates a page with 2 sets of tables with divs
      > around them.
      >
      > Each div tag has a name.
      > The first set of tags are as follows
      > div id="T123" STYLE="display: none;">
      > div id="T113" STYLE="display: none;">
      > etc
      >
      > I want to hide only the divs that start with T as I have others on the
      > page that I do not want to hide
      >
      > Can someone please tell me how to do this??[/color]

      solution 1:
      do not add STYLE="display: none;" to the second set.

      solution 2:
      add class: <div class="T" and <div class="nonT"

      solution 3: NOT TESTED !!! [IE only code]
      var coll = document.all.ta gs("DIV");
      if (coll!=null)
      for (i=0; i<coll.length; i++)
      if(coll[i].id.substr(1)!= "T")
      coll[i].style.display = "block"
      else
      coll[i].style.display = "none"



      --
      Evertjan.
      The Netherlands.
      (Please change the x'es to dots in my emailaddress)

      Comment

      • Lasse Reichstein Nielsen

        #4
        Re: Please help with a hiding DIV problem

        "Chris Hughes" <chris_hughes4N OSPAM@hotmail.c om> writes:
        [color=blue]
        > I have a routine that creates a page with 2 sets of tables with divs around
        > div id="T123" STYLE="display: none;">[/color]
        ....[color=blue]
        > I want to hide only the divs that start with T as I have others on the page
        > that I do not want to hide[/color]

        You can go through the divs one by one:

        var divs = document.getEle mentsByTagName( "div");
        for (var i=0;i<divs.leng th;i++) {
        if (divs[i].id.charAt(0)== "T") {
        divs[i].style.display = "none";
        }
        }

        /L
        --
        Lasse Reichstein Nielsen - lrn@hotpop.com
        Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
        'Faith without judgement merely degrades the spirit divine.'

        Comment

        Working...