|
|
 |
RE: FN-FORUM: JavaScript looping problem
date posted 16th February 2004 19:39
Thanks a lot for this Ron. Unfortunately I still can't get it working.
I've changed my function to this...
function showAllBranch(){
//get a pointer to the element
var objBranch = document.getElementById(branch);
//then you loop the childNodes array like this
for(i=0;iFrom: ron [EMAIL REMOVED]
>Reply-To: [EMAIL REMOVED]
>To: "FN-FORUM / [EMAIL REMOVED] [EMAIL REMOVED]
>Subject: RE: FN-FORUM: JavaScript looping problem
>Date: 16 Feb 2004 10:05:28 -0000
>
>
>Sorry it took so long to reply, I was banned from the pc this valentines
>weekend! :{
>
>objects have a childNodes array available in the DOM.
>
>so you do:
>
>//get a pointer to the element
>var objBranch = document.getElementById(branch);
>
>//then you loop the childNodes array like this
>
>for(i=0;i{
>objChild = objBranch.childNodes[i];
>objChild.display="block";
>}
>
>
>
>Little performance tip for you - switching from display none to display
>block is hard for the browser.
>
>But any element with a position: absolute style will take no space in the
>document flow, so you can use visibility: hidden instead.
>
>It's much easier for a browser to switch an element from hidden to visible,
>so I use this method on things like menus for a better response.
>
>HTH
>Ron
>
>-----Original Message-----
>From: [EMAIL REMOVED] [EMAIL REMOVED] Behalf Of Paul
>Cooper
>Sent: 15 February 2004 10:58
>To: FN-FORUM / [EMAIL REMOVED]
>Subject: FN-FORUM: JavaScript looping problem
>
>
>
>Hi
>
>I’ve got a JavaScript tree control function that works like this...
>
>function showBranch(branch){
> var objBranch = document.getElementById(branch).style;
> if(objBranch.display=="block")
> objBranch.display="none";
> else
> objBranch.display="block";
>}
>
>When this is triggered it displays a child node. I want to have another
>function that opens all the child nodes on the menu. So something like
>this...
>
>function showAllBranch(){
> for (var i=0;i var objBranch = document.getElementById('branch')+i.style;
> objBranch.display="block";
> i++;
> }
>}
>
>The part I can’t work out is how to pass the counter value into objBranch.
>So this bit is wrong...
>
>('branch')+i
>
>In ActionSript I’d do something like this...
>
>["branch"+i]
>
>I’ve tried all combinations I can think of but none work. Does anyone know
>the correct syntax?
>
>TIA
>Paul.
>
_________________________________________________________________
Tired of 56k? Get a FREE BT Broadband connection
http://www.msn.co.uk/specials/btbroadband
|
 |
|