Array loop, find:Control array : Two dimension array : Array « Language Basics « JavaScript DHTML

JavaScript DHTML
1.Ajax Layer
2.Data Type
3.Date Time
6.Dojo toolkit
8.Event onMethod
9.Ext JS
10.Form Control
11.GUI Components
13.Javascript Collections
14.Javascript Objects
15.Javascript Properties
17.Language Basics
20.Node Operation
21.Object Oriented
22.Page Components
27.Style Layout
30.Window Browser
31.YUI Library
JavaScript DHTML » Language Basics » Array 
Array loop, find:Control array : Two dimension array

     Example File From "JavaScript and DHTML Cookbook"
     Published by O'Reilly & Associates
     Copyright 2003 Danny Goodman

var myArray = ["Alice""Fred""Jean""Steve"];
for (var i = 0; i < myArray.length ; i++) {
    alert("Item " + i + " is:" + myArray[i".");


var nameList = ["Alice""Fred""Jean""Steve"];
var ageList = [23322824];
function ageLookup(name) {
    for (var i = 0; i < nameList.length ; i++) {
        if (nameList[i== name) {
            return ageList[i];
    return "Could not find " + name + ".";


function clearTextBoxes() {
    var allInputs = document.getElementsByTagName("input");
    for (var i = 0; i < allInputs.length; i++) {
        if (allInputs[i].type == "text") {
            allInputs[i].value = "";


var salesArray = [[2300310529094800]

var total = 0;
for (var i = 0; i < salesArray.length; i++) {
    for (var j = 0; j < salesArray[i].length; j++) {
        total += salesArray[i][j];

Related examples in the same category
1.Demo all methods in Array
2.Assing array value inside function
3.Simple Array Demo
4.Reversing, Sorting, and Concatenating an Array
5.Custom Numeric Comparison for the Array.Sort Method
6.Case-Insensitive Comparison for the Array.Sort Method
7.Iterating Through a Sparse Array
8.Using Functions to Iterate Through an Array
9.Reading and Writing Array Elements
10.Array with a numeric parameter and assign data to it
11.A string array
12.Array - properties and methods:length, join, reverse, push,pop,shift
13.Array - sort()
14.Array - concat and slice
15.Array - splice
16.Methods and Properties of the Array Object
17.Displaying the Contents of an Array
18.Using the Array.join() Method
19.Using JavaScript Arrays
20.Extending the Length of an Array
21.An Array within an Array
22.Using the Methods of the Array object
23.Array.sort() Possibilities
24.Array.reverse() Method
25. Array Concatenation
26.A Looping Array Lookup
27.A Simple Parallel Array Lookup
28.Adding a prototype Property
29.Two-Dimensional Array Work Around
30.Array definition and iteration
31.Reference an Array by index
32.URL Array
33.Array Utility functions
34.Dynamic array
35.Use for loop to display elements in an array
36.A string array variable
37.Queue based on array  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.