Solved

Javascript Multi-D Array!

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

895 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

18 Experts available now in Live!

Get 1:1 Help Now