469,306 Members | 1,590 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,306 developers. It's quick & easy.

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.getElementById(id).className!="root") {
var par=document.getElementById(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

Oct 25 '05 #1
6 1015
yoyoyo wrote on 25 okt 2005 in comp.lang.javascript:
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.getElementById(id).className!="root") {
var par=document.getElementById(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)


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.getElementById(id).className!="root") {
var par=document.getElementById(id).parentNode;
par.style.display="block";
par.nextSibling.style.backgroundColor="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='openParents("d5")'>show</button>
====================================

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

Oct 25 '05 #2
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".display: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:
yoyoyo wrote on 25 okt 2005 in comp.lang.javascript:
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.getElementById(id).className!="root") {
var par=document.getElementById(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)


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.getElementById(id).className!="root") {
var par=document.getElementById(id).parentNode;
par.style.display="block";
par.nextSibling.style.backgroundColor="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='openParents("d5")'>show</button>
====================================

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


Oct 25 '05 #3
yoyoyo wrote on 26 okt 2005 in comp.lang.javascript:
u
"you" please, and please do not toppost on usenet.
said that i cannot make somethingto be displayed:block if it is
contained inside something with display:none..

well, i don't agre..

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?
hey,
That is not my name.
thank u for your raply! i thought u were never going to help me!


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)

Oct 26 '05 #4
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:
yoyoyo wrote on 26 okt 2005 in comp.lang.javascript:
u


"you" please, and please do not toppost on usenet.
said that i cannot make somethingto be displayed:block if it is
contained inside something with display:none..

well, i don't agre..


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?
hey,


That is not my name.
thank u for your raply! i thought u were never going to help me!


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)


Oct 26 '05 #5
yoyoyo wrote on 26 okt 2005 in comp.lang.javascript:
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!


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)

Oct 26 '05 #6
Lee
yoyoyo said:

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


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.

Oct 26 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

72 posts views Thread by E. Robert Tisdale | last post: by
121 posts views Thread by typingcat | last post: by
28 posts views Thread by Madhur | last post: by
13 posts views Thread by Jason Huang | last post: by
669 posts views Thread by Xah Lee | last post: by
3 posts views Thread by Siong.Ong | last post: by
16 posts views Thread by John Doe | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.