Page 1 of 1

access 'array variables'

Posted: Wed May 09, 2007 10:22 am
by GeXus
I don't know what this is called.. But here is what I'm doing

Code: Select all

var i=0;
		   for (i=0; i<4; i++) 
			{
		   
                    		var oTextNode = new YAHOO.widget.TextNode(myobj.Roots[i], root, false);

			}
As you can see, It's looping through 4 times and assigning oTextNode each time...

How do I access each instance of oTextNode? I feel like I should be able to do something like oTextNode[1] for example.... OR is there a way to have a dynamic variable.... like instead of oTextNode have it "oTextNode + i"

Thanks for your help!

Posted: Mon May 14, 2007 7:42 am
by feyd
oTextNode is a single instance variable, not an array, so only the last one will have an instance. Dynamic variables are not supported as they are in PHP.

Create an array outside the loop, then fill it with the four instances.