SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: dropdown lists

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2006
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    dropdown lists

    I have three dropdown lists (country, city, hotel).

    The steps are like this:
    1.countries name shows in the country dropdown list, city and hotel dropdown lists are empty.
    2. select country, then the city dropdown lists will show the cities in the selected country only.
    3. select a city, then the hotel dropdown lists will show the hotels in the selected city only.

    list of countries, cities and hotels are all from database.
    How can I do this using javascript?

  2. #2
    SitePoint Zealot
    Join Date
    Dec 2006
    Posts
    182
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use an XMLHttpRequest object to call a php/asp/etc script that calls the database and returns the selected list, then parse the list of options into the select box.

    http://www.w3schools.com/dom/dom_http.asp

  3. #3
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I recently wrote a demo for someone requesting something similar to this. It doesn't use XHR but it might give you some ideas.


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
  •