0

Hi,

Can anyone help me with dynamically adding to a multidimensional javascript array that has an arbitary number of dimensions?

Something like:
myArray [5] [4] = 'hello';

That code does not work unless the cells were populated when the array was defined+initialized. So you can't add new cells or dimensions like this. But how do you add them?

Thanks in advance.

2
Contributors
2
Replies
3
Views
10 Years
Discussion Span
Last Post by cycleops
0

You would need to do somethng like this:

tmenu[3] = [["Departments", "#", "dropdown"]];
		smenu[3] = new Array(); fmenu[3] = new Array();
		smenu[3][1] = [["Administration", "#", "noFlyout"]];
		smenu[3][2] = [["Human Resources", "#", "flyout"]];
			fmenu[3][2] = new Array();
			fmenu[3][2][1] = [["Home Page", "#"]];
			fmenu[3][2][2] = [["Employment Opportunities", "#"]];
			fmenu[3][2][3] = [["Teach in Iowa", "#"]];
			fmenu[3][2][4] = [["Info for Teacher Candidates", "#"]];
			fmenu[3][2][5] = [["Master Contract", "#"]];
			fmenu[3][2][6] = [["Iowa Teaching Standards", "#"]];
			fmenu[3][2][7] = [["Non-Discrimination Policy", "#"]];

The problem you run into with your way is that "hello" is an array of characters...so the elements of the array are 'h', 'e', 'l' 'l', and 'o'.

0

great!
i thought this was forgotten.
thanks a lot.
very kind of u.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.