Solved

Javascript Multi-D Array!

Posted on 2000-03-30
5
143 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
  • 3
5 Comments
 
LVL 2

Expert Comment

by:mblase
Comment Utility
So, what's the question?...
0
 
LVL 1

Accepted Solution

by:
tarassov earned 50 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
it ok - my array was of size 0 - hence the problem!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
Showing your events from Google Calendar in Google Maps Why? I travel all week and I thought it would be ideal if staff in office knew where I was based on my calendar. (OK real reason: my son wanted to see where I would be working, and I thoug…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

772 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now