Results 1 to 2 of 2

Thread: prepopulate a drop down list from sql database

  1. #1
    Join Date
    May 2009
    Location
    Greensboro, GA
    Posts
    163
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default prepopulate a drop down list from sql database

    I have a form with a drop down list. Some of this form has been prepopulated with data from a mysql database. Everything else is working except I don't know how to prepopulate the drop down list.
    I hope I explained this right.

    Example:
    Drop down list options: 1, 2, 3, 4, 5
    data from mysql: 3
    So when the user gets to the drop down list, he sees 3 selected and he can then change it
    Thanks for any help
    Last edited by mcolton; 01-09-2010 at 07:00 PM.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Looks like this was solved. For anyone else with a similar question, here are the basic steps:
    1. Use PHP or another server side language to gather the relevant information from the database.
    2. Use that language to then output the TEXT of the javascript for the dropdown menu, such as:
    echo 'mymenu[] = "item1";';
    (repeat for each item).
    3. Then Javascript will have the information when the page loads.

    (Remember: there is no easy way to get the data using Javascript, so "prepopulating" it is the best approach.)
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •