Solved

Javascript Multi-D Array!

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

770 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