This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Populating HTML select using JSON Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Populating HTML select using JSON" Watch "Populating HTML select using JSON" New topic

Populating HTML select using JSON

amit punekar
Ranch Hand

Joined: May 14, 2004
Posts: 511
I have 3+ HTML Select inputs(Dropdowns) on one HTML. After changing one of them I want to update select options in other dropdowns based on the selection.
I am using Prototype to execute the AJAX call. I worked it out for two dropdowns wherein Ajax response contained only values for one of the dropdowns.
I am planning to send back values for all dropdowns in one server hit. I was looking at probable solutions, JSON being one of them.
I know that if I can send the JSON objects from server side I can use them to populate the Dropdown boxes.
The thing I want to know is there anyway in Prototype library/HTML DOM that can take JSON Array as an input to populate the HTML Select.


Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60765

No. You'll need to iterate through the data and construct the option elements.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
amit punekar
Ranch Hand

Joined: May 14, 2004
Posts: 511
Thanks Bear for prompt response.

I agree. Here's the link:
subject: Populating HTML select using JSON
Similar Threads
AJAX, DOM, and history
How to solve this
Christian - Most robust AJAX library
How to fill values in selectbox dynamically
Ajax drop down