This week's book giveaway is in the iOS forum.
We're giving away four copies of Classic Computer Science Problems in Swift and have David Kopec on-line!
See this thread for details.
Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Ranch Hand
Posts: 964
2
  • 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.
 
Author and ninkuma
Marshal
Posts: 66608
161
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!