Create Javascript Arrays with Database Values

Posted on 2006-04-27
Last Modified: 2010-04-06
We have over 1900 employees in our organization and at times it is kind of annoying to go through an entire dropdown to select an employees name from a list. What I would like to do is create 2 dropdowns on the form.

The 1st option - The user would select a section of the alphabet (a-c, d-f, etc)

The 2nd option - Would then contain the users name (retrieved from the database) that begins with the letter selected in the 1st option.

1st - Can this be done in Javascript. I know I can pass option 1 back to the page. But a lot of times my user is just to impatient to wait for it to refresh, therefore I would like to be able to do it with Javascript. I know that I can create two dropdowns where the second value is created based on the first one. But I have never done this with information that is in the database.

Any help would be greatly appreciated.

Thanks in advance
Question by:laevans
    1 Comment
    LVL 6

    Accepted Solution

    You will need to create an array of arrays.  The initial selection in your first dropdown will govern which array to load into your second dropdown.  You will populate all of the arrays when the page initially loads with the values from your db.

    Here is a link to a short tutorial:

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: HTML5 Mobile App Development with PhoneGap

    PhoneGap can help you leverage your already existing HTML5, JavaScript, and CSS skills in order to create and deploy cross-platform mobile apps.This program comprehensively covers HTML5 mobile app development from top to bottom.

    Suggested Solutions

    Title # Comments Views Activity
    Xsl Nested Loop 4 18
    Migrating to Exchange 2013 4 36
    API Blueprint array help 1 184
    Asynchronous REStful Http timer based Calls C# Issue 12 118
    Article by: Matthew
    I am a very big proponent of technology compliance standards and strive to meet such criteria in all of my work. That includes my site, which is 100% XHTML 1.0 compliant as determined by the World Wide Web Consortium. https://www.matthewstevenkel…
    I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now