23
Jan

Create two dimensional arrays

   Posted by: Pradeep   in Scripting

Lets understand how to create a two dimensional javascript arrays. First create a singular list of arrays

var country0StateList = new Array("Country0-State0","Country0-State1","Country0-State2","Country0-State3");
var country1StateList = new Array("Country1-State0","Country1-State1","Country1-State2","Country1-State3");
var country2StateList = new Array("Country2-State0","Country2-State1","Country2-State2","Country2-State3");
var country3StateList = new Array("Country3-State0","Country3-State1","Country3-State2","Country3-State3");

Create an array of arrays with

var countries = new Array(country0StateList,country1StateList,country2StateList,country3StateList);

Voila, the variable countries now is a two dimensional array.

Tags:

This entry was posted on Friday, January 23rd, 2009 at 4:30 pm and is filed under Scripting. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a reply

Name (*)
Mail (will not be published) (*)
URI
Comment