|
|||||||
| JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...) |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Complex arrays
I think the answer to this is probably quite simple, but I can't find a sample of similar code. Maybe there is a better way of doing what I want.
I would like a form with two <SELECT> lists. The first list includes company names. The company names are stored in an array. The second list includes employee names. The employee names are also in an array. My first questio: it it possible to give the employee array 2 indexes (indices!?), the first being company and the second being the employee. I guess I would reference the array like this .... $employee = emparray[0][0]; $employee2 = emparray[0][1]; $employeex = emparray[2][1]; etc How do I build such an array? The contents of my drop-down lists will be fetched from a database by my PHP code. I'm guessing that I will need my PHP code to dynamically build these arrays. Anyone with a suggestion for a better method feel free to say. Thanks
__________________
....Rodders |
|
#2
|
||||
|
||||
|
I would not go with 2d array for this task but rather with objects:
Code:
//declaration
function emloyee(firstName,lastName)
{ this.firstName = firstName;
this.lastName = lastName;
}
function.company(employees)
{ this.employees = employees;
}
//initialization
company1 = new company (new Array(
new employee('Tom','Smith'),
new employee('Bill','Jackson'),
....
new employee('Steve','Simpson')));
company2 = ...
companies = new Array(company1,company2,...);
__________________
Vladdy Working web site is not the one that looks the same in a few graphical browsers, but the one that adequately delivers its content to any device accessing it. |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|