Hi coothead
I am trying to create a multi-dimensional array and one that is indexed.
The basic function this script needs to replicate is the ability to look in multi-dimensional arrays for a value.
Code:
<script type="text/javascript">
myDB=new Array();
item1='1';
item2='2';
item3='3';
item4='four';
myDB.push(item1+item2+item3+item4);
alert(myDB[0][3]);
if(myDB[0][3]=='four') {
alert(myDB[0][3]);
}
</script>
Your code works but when you throw a value with more than one character you'll see the code above returns "f" instead of "four" because the array within the array is not indexed.
The line below seems to work
Code:
myDB = new Array(new Array(item1, item2, item3, item4)) ;
However, I am working with the push method to populate an array's node with another array, which does not seem to work on the fly.
Bookmarks