access 'array variables'

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

access 'array variables'

Post 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!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

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