Solved

Javascript Multi-D Array!

Posted on 2000-03-30
5
148 Views
Last Modified: 2010-04-09
I need 3 arrays for some js code I'm trying to build!

1st one is 1 dimensional
i.e list1_array[i]
2nd one is 2 dimensional
i.e list2_array[j][k]
3rd one is 3 dimensional
i.e list3_array[l][m][n]
This is what I have so far which falls over in the inner loop..

<html>
<head>
<script>
<!--

var list1_array=new Array();
var list2_array=new Array();

for(i=0;i<7;i++)
{
      list2_array[i]=new Array();
      var list3_array[i]=new Array();      
      
      for(k=0; k<26;k++)
      {
            list3_array[i][k]=new Array();
      }
}
</script>
</head>
0
Comment
Question by:ruperts
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 2

Expert Comment

by:mblase
ID: 2670040
So, what's the question?...
0
 
LVL 1

Accepted Solution

by:
tarassov earned 50 total points
ID: 2670068
Maybe you should try something like the code below? The problem is that you have redeclared list3_array in the first(outer) cycle - and exactly in a wrong way: the string
var list3_array[i]=new Array();
is wrong. Hope the code below will help you!

Andrey


<html>
<head>
<script>
<!--

var list1_array=new Array();
var list2_array=new Array(7);
var list3_array=new Array(7);

for(i=0;i<7;i++)
{
list2_array[i]=new Array();
list3_array[i]=new Array(26);

for(k=0; k<26;k++)
{
list3_array[i][k]=new Array();
}
}
</script>
</head>

0
 
LVL 4

Author Comment

by:ruperts
ID: 2672268
tarassov:
Thanks - no problems so far!

MBlase:
"This is what I have so far which falls over in the inner loop.. "

Which translates to "help why does it fall over in the inner loop" ;-)
0
 
LVL 4

Author Comment

by:ruperts
ID: 2672355
help...
can not refer to the to my array!

i.e.

list2_array[0][0] = new Option("XXXX");

I get list2_array.0 is not an object.
0
 
LVL 4

Author Comment

by:ruperts
ID: 2672366
it ok - my array was of size 0 - hence the problem!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question