prism
03-11-2005, 08:23 PM
I'm having trouble using the contents of an array as an index into another, for example I have an array1 which holds the values 4,5,6. and I want to access array2[4] array2[5] array2[6].
The code I've been trying to use is something like:
for(i = 1; i < 3; i++)
{
alert(array2[ array1[i] ]);
}
I've also tried assigning the contents of array1 to another variable 'j' and using that as the index.
for(i = 0; i < 3; i++)
{
j = array1[i];
alert(array2[j]);
}
If anybody can help I would greatly appreciate it.
Thanks.
The code I've been trying to use is something like:
for(i = 1; i < 3; i++)
{
alert(array2[ array1[i] ]);
}
I've also tried assigning the contents of array1 to another variable 'j' and using that as the index.
for(i = 0; i < 3; i++)
{
j = array1[i];
alert(array2[j]);
}
If anybody can help I would greatly appreciate it.
Thanks.