Solved

Javascript Multi-D Array!

Posted on 2000-03-30
5
147 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
send email part1 9 41
Bootstrap 3 - Style a dropdown 1 28
Use "if not" in a condition 2 19
asp.net, radiobuttonlist, c# 3 40
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
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 …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

730 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