Home arrow JavaScript arrow Page 3 - An in depth discussion of JavaScript Arrays
JAVASCRIPT

An in depth discussion of JavaScript Arrays


This series of articles mainly concentrates on working with JavaScript arrays. We shall start with the basics of JavaScript arrays and finally conclude with complex object based arrays in JavaScript. You can reuse these scripts to inject into server side controls easily (especially in .NET and Java).

Author Info:
By: Jagadish Chaterjee
Rating: 3 stars3 stars3 stars3 stars3 stars / 9
February 28, 2006
TABLE OF CONTENTS:
  1. · An in depth discussion of JavaScript Arrays
  2. · Working with single dimensional arrays: discussion
  3. · Working with two dimensional arrays
  4. · Working with two dimensional arrays: discussion
  5. · Another way to work with two dimensional arrays

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
An in depth discussion of JavaScript Arrays - Working with two dimensional arrays
(Page 3 of 5 )

In the above two sections, we only worked with single dimensional arrays (arrays with only one level of indexing).  Now, we shall deal with two dimensional arrays (arrays with two levels of indexing). 

Now, let us try to develop a simple script (JavaScript) to declare and work with two dimensional arrays.  Have a look at the following code:

<html>
      <head>
           <meta name=vs_targetSchema 
content="http://schemas.microsoft.com/intellisense/ie5">
<script id="clientEventHandlersJS" language="javascript">
<!--
function Show()
{
      var ITArray = new Array(2300, 3105, 2909, 4800);
      var ProductionArray = new Array(1800, 1940, 2470, 4350);
      var ResearchArray = new Array(900, 1200, 1923, 3810);
      var salaryArray = new Array(ITArray, ProductionArray, ResearchArray);

      for (var i = 0; i < salaryArray.length; i++) {
            for (var j = 0; j < salaryArray[i].length; j++) {
                  document.write(salaryArray[i][j] + "\t");
            }
            document.write("<br>")
      }
}

function
ButtonShow_onclick() {
      Show();
}
//-->
            </script>
      </head>
      <body>
      <form id="form1">
                  <input type="button" value="Show" id="ButtonShow" 
name="ButtonShow" onclick="return ButtonShow_onclick()">
            </form>
      </body>
</html>

Actually, within the above code, the “meta” tag is not necessary.  As I developed the above code using Visual Studio.NET 2003 Enterprise Architect, it was automatically added to provide its full featured mechanisms.  The explanation for the above code is discussed in the next section.


blog comments powered by Disqus
JAVASCRIPT ARTICLES

- More Top jQuery Tutorials for Beginners
- More Top jQuery Plugins for Menus
- Top jQuery Tutorials for Beginners
- New UI Framework and SDK for JavaScript Rele...
- JavaScript OpenPGP Tool, Node.js 0.6.3 Avail...
- Yahoo Releases Cocktails Language and Develo...
- Customizing jQuery Slideshows: Dynamic Contr...
- Customizing jQuery Slideshows: the animate()...
- Customizing jQuery Slideshows: slideUp() and...
- Customizing jQuery Slideshows: hide() and sh...
- Web Workers: Performing Calculations in Para...
- More Top JavaScript Frameworks and Libraries
- More Dynamic jQuery Styling Techniques
- The Top JavaScript Libraries
- The Top JavaScript Frameworks

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 8 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials