aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes trying to populate Cities dropdown on Onselect of States dropdown using AJAX. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "trying to populate Cities dropdown on Onselect of States dropdown using AJAX." Watch "trying to populate Cities dropdown on Onselect of States dropdown using AJAX." New topic
Author

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

Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 644
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

Joined: Jan 10, 2002
Posts: 61218
    
  66

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: trying to populate Cities dropdown on Onselect of States dropdown using AJAX.