User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 397,802 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,426 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1530 | Replies: 2
Reply
Join Date: Sep 2006
Posts: 3
Reputation: cycleops is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
cycleops cycleops is offline Offline
Newbie Poster

Question multidimensional arrays, adding to

  #1  
Sep 29th, 2006
Hi,

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

Something like:
myArray [5] ['aKey'] [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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2004
Location: Hemet, CA
Posts: 427
Reputation: FC Jamison is on a distinguished road 
Rep Power: 5
Solved Threads: 17
Colleague
FC Jamison's Avatar
FC Jamison FC Jamison is offline Offline
Posting Pro in Training

Re: multidimensional arrays, adding to

  #2  
Oct 7th, 2006
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'.
Reply With Quote  
Join Date: Sep 2006
Posts: 3
Reputation: cycleops is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
cycleops cycleops is offline Offline
Newbie Poster

Re: multidimensional arrays, adding to

  #3  
Oct 9th, 2006
great!
i thought this was forgotten.
thanks a lot.
very kind of u.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 6:05 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC