[Javascript] Help with function containing array

Pitre, Russell RPITRE at shawmut.com
Tue Aug 10 14:06:28 CDT 2004


Hello all-

 

I have these functions below.  I need to have a "department" object
contain an array of "division" objects.   I'm not sure how to
department[0].divisions with an array of divisions.  I'm thinking my
problem is how I'm setting "this.divisions" in the department object.

 

 

 

var departments = new Array();

var divisions = new Array();

 

function division (id, name) {

            this.id = id;

            this.name = name;

} 

 

function department(id, name, divisions){

            this.id = id;

            this.name =name;

            //  PROBLEM HERE!!!  I think

            this.divisions = divisions;

}

 

// My Accounting Divsions

divisions[0] = new division(1, "Accounts Payable");

divisions[1] = new division(2, "Account Recievable");

divisions[2] = new division(3, "Payroll");

 

// My Account departing containg id, name, and it's divisions

departments[0] = new department(1, "Accounting", divisions);

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20040810/6ffb930a/attachment.htm>


More information about the Javascript mailing list