what's wrong in here?!!?

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

    what's wrong in here?!!?

    hi guys,
    i'm developing a function that having as argument the branch of a
    structured tree returns the tree showing only the parents of that
    branch..

    the function that doesn't work is the following:

    function openParents(id) {
    if (document.getEl ementById(id).c lassName!="root ") {
    var par=document.ge tElementById(id ).parentNode;
    par.nextSibling .style.display= "block";
    openParents(par .id)
    }
    }

    this function should recall itself in order to open all the ancestors..
    i really cannot understand why it doesn't work!

    (the argument given is the id of a branch)

    thank u to everyone!
    teo

  • Evertjan.

    #2
    Re: what's wrong in here?!!?

    yoyoyo wrote on 25 okt 2005 in comp.lang.javas cript:
    [color=blue]
    > hi guys,
    > i'm developing a function that having as argument the branch of a
    > structured tree returns the tree showing only the parents of that
    > branch..
    >
    > the function that doesn't work is the following:
    >
    > function openParents(id) {
    > if (document.getEl ementById(id).c lassName!="root ") {
    > var par=document.ge tElementById(id ).parentNode;
    > par.nextSibling .style.display= "block";
    > openParents(par .id)
    > }
    >}
    >
    > this function should recall itself in order to open all the ancestors..
    > i really cannot understand why it doesn't work!
    >
    > (the argument given is the id of a branch)[/color]

    You cannot display the next sibling if the parent is display:none;.

    Colouring the siblings, and displaying just the parents works great (IE):

    =============== ===============
    <style>
    div {display:none;}
    </style>
    <script type="text/javascript">
    function openParents(id) {
    if (document.getEl ementById(id).c lassName!="root ") {
    var par=document.ge tElementById(id ).parentNode;
    par.style.displ ay="block";
    par.nextSibling .style.backgrou ndColor="red";
    openParents(par .id)
    }
    }
    </script>

    <div class='root'>
    root<br>
    <div id='d1'>
    d1<br>
    <div id='d2'>
    d2<br>
    <div id='d3'>
    d3<br>
    <div id='d4'>
    d4<br>
    <div id='d5'>
    d5<br>
    </div><span>1</span>
    </div><span>2</span>
    </div><span>3</span>
    </div><span>4</span>
    </div><span>5</span>
    </div><span>6</span>
    <button onclick='openPa rents("d5")'>sh ow</button>
    =============== =============== ======

    --
    Evertjan.
    The Netherlands.
    (Replace all crosses with dots in my emailaddress)

    Comment

    • yoyoyo

      #3
      Re: what's wrong in here?!!?

      hey, thank u for your raply! i thought u were never going to help me!
      actually i didn't understood so well what u said to me..
      u said that i cannot make somethingto be displayed:block if it is
      contained inside something with display:none..

      well, i don't agre..
      i mean: of course i won't see anything inside an element with
      display:bock, but as soon as i make the "container".dis play:block i
      will also see everything inside..

      don't u think so?

      i'm just trying to start from the branches to make them visible to
      arrive till the root node, as i thinku understood..
      teo



      Evertjan. ha scritto:
      [color=blue]
      > yoyoyo wrote on 25 okt 2005 in comp.lang.javas cript:
      >[color=green]
      > > hi guys,
      > > i'm developing a function that having as argument the branch of a
      > > structured tree returns the tree showing only the parents of that
      > > branch..
      > >
      > > the function that doesn't work is the following:
      > >
      > > function openParents(id) {
      > > if (document.getEl ementById(id).c lassName!="root ") {
      > > var par=document.ge tElementById(id ).parentNode;
      > > par.nextSibling .style.display= "block";
      > > openParents(par .id)
      > > }
      > >}
      > >
      > > this function should recall itself in order to open all the ancestors..
      > > i really cannot understand why it doesn't work!
      > >
      > > (the argument given is the id of a branch)[/color]
      >
      > You cannot display the next sibling if the parent is display:none;.
      >
      > Colouring the siblings, and displaying just the parents works great (IE):
      >
      > =============== ===============
      > <style>
      > div {display:none;}
      > </style>
      > <script type="text/javascript">
      > function openParents(id) {
      > if (document.getEl ementById(id).c lassName!="root ") {
      > var par=document.ge tElementById(id ).parentNode;
      > par.style.displ ay="block";
      > par.nextSibling .style.backgrou ndColor="red";
      > openParents(par .id)
      > }
      > }
      > </script>
      >
      > <div class='root'>
      > root<br>
      > <div id='d1'>
      > d1<br>
      > <div id='d2'>
      > d2<br>
      > <div id='d3'>
      > d3<br>
      > <div id='d4'>
      > d4<br>
      > <div id='d5'>
      > d5<br>
      > </div><span>1</span>
      > </div><span>2</span>
      > </div><span>3</span>
      > </div><span>4</span>
      > </div><span>5</span>
      > </div><span>6</span>
      > <button onclick='openPa rents("d5")'>sh ow</button>
      > =============== =============== ======
      >
      > --
      > Evertjan.
      > The Netherlands.
      > (Replace all crosses with dots in my emailaddress)[/color]

      Comment

      • Evertjan.

        #4
        Re: what's wrong in here?!!?

        yoyoyo wrote on 26 okt 2005 in comp.lang.javas cript:
        [color=blue]
        > u[/color]

        "you" please, and please do not toppost on usenet.
        [color=blue]
        > said that i cannot make somethingto be displayed:block if it is
        > contained inside something with display:none..
        >
        > well, i don't agre..
        >[/color]

        The facts show you are wrong:

        <div style='display: none;'>
        Suppressed
        <div style='display: block;'>
        Can you read this? No way!
        </div>
        </div>

        Did you test it out before not agreeing?
        [color=blue]
        > hey,[/color]

        That is not my name.
        [color=blue]
        > thank u for your raply! i thought u were never going to help me![/color]

        Good thought, if you don't follow Netiquette you won't get much help.
        The asking has to follow customs of the asking game.

        --
        Evertjan.
        The Netherlands.
        (Replace all crosses with dots in my emailaddress)

        Comment

        • yoyoyo

          #5
          Re: what's wrong in here?!!?

          i tried to be polite, i thanked u for your help, why should u continue
          to tell me "don't use this" "don't say that" "hey is not my name"..
          ??? i really don'T understand u..

          anyway, of course i've tried before to post..in the function i'm
          developing i'm setting display:block from the last branch till the
          first root..as u can see from the code i've postes, that function
          recall itself..

          of course if u just set display:block on the branch and not on the root
          u cannot see anything..but is u then continue and set block also to the
          previous root u'll see evrything!



          Evertjan. ha scritto:
          [color=blue]
          > yoyoyo wrote on 26 okt 2005 in comp.lang.javas cript:
          >[color=green]
          > > u[/color]
          >
          > "you" please, and please do not toppost on usenet.
          >[color=green]
          > > said that i cannot make somethingto be displayed:block if it is
          > > contained inside something with display:none..
          > >
          > > well, i don't agre..
          > >[/color]
          >
          > The facts show you are wrong:
          >
          > <div style='display: none;'>
          > Suppressed
          > <div style='display: block;'>
          > Can you read this? No way!
          > </div>
          > </div>
          >
          > Did you test it out before not agreeing?
          >[color=green]
          > > hey,[/color]
          >
          > That is not my name.
          >[color=green]
          > > thank u for your raply! i thought u were never going to help me![/color]
          >
          > Good thought, if you don't follow Netiquette you won't get much help.
          > The asking has to follow customs of the asking game.
          >
          > --
          > Evertjan.
          > The Netherlands.
          > (Replace all crosses with dots in my emailaddress)[/color]

          Comment

          • Evertjan.

            #6
            Re: what's wrong in here?!!?

            yoyoyo wrote on 26 okt 2005 in comp.lang.javas cript:
            [color=blue]
            > of course if u just set display:block on the branch and not on the root
            > u cannot see anything..but is u then continue and set block also to the
            > previous root u'll see evrything!
            >[/color]

            You only displayed the siblings, not the parents.

            This is my last answer if you don't follow the NG's rules.

            --
            Evertjan.
            The Netherlands.
            (Replace all crosses with dots in my emailaddress)

            Comment

            • Lee

              #7
              Re: what's wrong in here?!!?

              yoyoyo said:[color=blue]
              >
              >i tried to be polite, i thanked u for your help, why should u continue
              >to tell me "don't use this" "don't say that" "hey is not my name"..
              >??? i really don'T understand u..[/color]

              You haven't tried hard enough to be polite.

              You've been asked to show us the courtesy of posting in a form
              that suggests that you have some respect for the people who are
              considering offering help.

              It shouldn't matter whether or not you understand *why* we ask
              you to do this. As a matter of courtesy, you should comply.

              Comment

              Working...