This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Populating the Drop-down Box 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 "Populating the Drop-down Box using Ajax" Watch "Populating the Drop-down Box using Ajax" New topic
Author

Populating the Drop-down Box using Ajax

Jahnavi Kondapaneni
Ranch Hand

Joined: Jan 25, 2008
Posts: 56
Hi all,

I am having a dropdown list box which displays the different states like "Andhra Pradesh","Karnataka"...etc.
On selection of one of the states I need to populate another drop-down box with the list of cities that come under that state.
Now I know that I can call a function onchange and create xmlHttp object and send the request along with the parameters.
Like <select name="state" onchange="validate()">
My question is how do I display another dropdown box with the values of cities in it once the state is selected.
Hope I made my question clear....
Jahnavi Kondapaneni
Ranch Hand

Joined: Jan 25, 2008
Posts: 56
Since I want to populate the drop down list box.
The response will be in form of an array.
How do I handle the response which is of the form Array
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63208
    
  69

You'd iterate through the array and create option elements for each, adding them to the select element. The API for the select element is straight-forward.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Populating the Drop-down Box using Ajax
 
It's not a secret anymore!