SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Nov 2008
    Location
    Portugal (Viseu)
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Using AJAX so fill <select>

    I'm having a problem with 2 select items.
    One is "contry" and other is "city". To fill both of them, i use some PHP. It search on database for all countries and using a while, i create all the options (the same for city).
    But now i need to limit the city select.
    My tables are:
    Contry
    -ID
    -name

    City
    -ID
    -name
    -country

    I need a AJAX code, to when i change country ID, makes a SELECT on table city and return all cityes where "country" from table City is the same as "ID"
    from table Country.
    I already search for some tutorials but i can't make this :/
    Can someone help me doing this?
    Thanks

  2. #2
    SitePοint Troll disgracian's Avatar
    Join Date
    Aug 2006
    Location
    Samsara
    Posts
    451
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There are two perfectly good tutorials on this very site:

    Cheers,
    D.

  3. #3
    SitePoint Member
    Join Date
    Nov 2008
    Location
    Portugal (Viseu)
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Disgracian, thank you for the reply.
    I'm now starting to read "Ajax for Dummies (2008)" and i'm very exciting. It's the first time that i learn javascript, and i hope in somedays i'll be able to create the script that i need to fill the select!
    When i finished it, i post here the code.
    Thank you for the advice

  4. #4
    SitePοint Troll disgracian's Avatar
    Join Date
    Aug 2006
    Location
    Samsara
    Posts
    451
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good to hear. One nice thing about jumping into Javascript with AJAX is most of the tutorials will teach proper (or at least better) usage of Javascript than the ones that use document.write() and you'll avoid a lot of bad habits that many of us had to train ourselves out of.

    Good luck with your learning!

    Cheers,
    D.


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
  •