File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes 'mulit-dimensional' arrays in javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark " Watch " New topic

'mulit-dimensional' arrays in javascript

Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
I could've swore you can create 2d arrays in javascript literally.

something like so...

how do I make one literally?


Justin Fox

You down with OOP? Yeah you know me!
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60782

Hint: [[],[],[]]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
yeah, I finally figured it out, I had the array coming back from the server in this format:

and in client side when in eval that text and loop through
it gave me this

a,b,c a,b,c a,b,c
a,b,c a,b,c a,b,c

But when I set it up in this format:

it looped through and printed it fine:

a b c
a b c
a b c

was weird, but I got it working.

Justin Fox
I agree. Here's the link:
subject: 'mulit-dimensional' arrays in javascript
Similar Threads
How to write retrieved data into javascript Array?
Better way of doing this?
IE9 javascript undefined errors
Array object vs. an array
Problems with arrays & for loops