www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > JavaScript

    JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...)

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 11-27-2002, 08:24 AM
    Rodders Rodders is offline
    Registered User
     
    Join Date: Nov 2002
    Location: Peterborough, UK
    Posts: 163
    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
    Reply With Quote
      #2  
    Old 11-27-2002, 10:32 AM
    Vladdy's Avatar
    Vladdy Vladdy is offline
    Helper, not pleaser
     
    Join Date: Nov 2002
    Location: Nashua, NH
    Posts: 3,222
    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.
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 03:19 AM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.