Library code snippets

Building a MultiDimensional Array in Javascript

Building a MultiDimensional Array in Javascript The MultiDimensional Array
is zero based.  In the following example the array range is [0..6][0..1].


Implementation:

var sDataArray=MultiDimensionalArray(7,2);
alert(sDataArray[0][0]);
Code
function MultiDimensionalArray(iRows,iCols)
{
var i;
var j;
   var a = new Array(iRows);
   for (i=0; i < iRows; i++)
   {
       a[i] = new Array(iCols);
       for (j=0; j < iCols; j++)
       {
           a[i][j] = "";
       }
   }
   return(a);
}

Comments

  1. 02 Aug 2002 at 07:28

    Hello,


    I 'ld like to know how you can fill such a multidimensional array with a recordset from a MySQL database.


    I can fill a selectbox with a query result with PHP.
    Now what I want to do is make a selection in one selectbox that reflects on the option in the other select-box.
    as seen on this page! Cool link!


    All need to know is how I can get the associative multidimensional PHP-array (the query-result) in the multidimensional JS-array to fill the select-boxes.


    I suppose I can loop through the JS-array and fill in the PHP-values when the page loads.


    I'll post the code if I find a solution.


    I hope someone can give me some tips.

  2. 01 Jan 1999 at 00:00

    This thread is for discussions of Building a MultiDimensional Array in Javascript.

Leave a comment

Sign in or Join us (it's free).

David Nishimoto NishiSoft provides Part I of the Information Technology Project collaboration. Sign up and list your IT project tasks, assign task too friends, and get percent complete task. Part will include a wo...

Related podcasts

  • The Future of .NET Dotfuscator with Gabriel Torok

    Keith and Woody sat down with PreEmptive President Gabriel Torok to discuss the news that Microsoft is including PreEmptive's Dotfuscator Community Edition in Visual Studio 2010. The guys also discussed how Dotfuscator can be used to assist with Feature Monitoring, Usage Expiry, and Tamper ...

Events coming up

  • Dec 15

    Portland Java User Group

    Portland, United States

    This month's topic: TBD----------PJUG meetings start with eat+meet+greet time (pizza and beverages are provided), followed by the featured speaker, then some time for Q&A, discussion, and sometimes a drawing to give away swag. :)It is...

Want to stay in touch with what's going on? Follow us on twitter!