•
•
•
•
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
![]() |
•
•
Join Date: Sep 2006
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 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] ['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.
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.
You would need to do somethng like this:
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'.
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'.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
- (reformatted) How to return Multi-Dimensional Arrays (C++)
- Initializing Multidimensional Arrays plz help! (C++)
- What relation does **indirection operator have with Multidimensional Arrays (C++)
- Java Multidimensional Arrays (Java)
- How to Return Multidimensional Arrays (C++)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Drop Down Menu - Problem Opening in IE
- Next Thread: How do I place images on a rotating divided cube using Javascript?


Linear Mode