• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

trying to populate Cities dropdown on Onselect of States dropdown using AJAX.

 
Monica Shiralkar
Ranch Hand
Posts: 842
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to populate Cities dropdown on Onselect of States dropdown using AJAX. I know that on Onselect I can call a Ajax javascript with parameter as state code fetch cities using it.Now I know how to display this data using id.but I need to populate the other dropdown.

Once I have fetched the data using AJAX how to populate the cities dropdown.Please advice.Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64958
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use a change handler, not select.

Have the response contain the new set of options elements, and simply use .load() to inject them into the select element.

I show how to do this in chapter 8 of jQuery in Action (2nd Ed). Download the free example code if you just want to see the code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic