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.

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.