Take the 2-minute tour ×

My task is to populate another select list based on what is choosen from one select list, querying populating data from database.

I think it goes something like:

  2. On select list onChange method a query like select id, description from table where child_id=_id_ is executed.
  3. Child select list is populated based on that query. Maybe the result of query is returned in a controller method?


share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

I would like to recommend you to use Google, because simple search will provide you the answer.

This code sample will show you the way how to do it:

    $.getJSON("/getSubCategories?id="+$(this).val(), function(j){
      var options = '';

Now the Server side:

@RequestMapping(method = RequestMethod.GET, value = "/getSubCategories")
public String handleRequest( @RequestParam("id") int id) {) {
now build your json string as optionValue and OptionDisplay.
String json = service.getSubCategories(id);
 return json;
share|improve this answer
What keywords did you use? I tried google.. –  mjgirl Jul 25 '11 at 8:51
How to build the json String ??? –  Abhishek Singh Oct 9 '13 at 10:57
add comment

Your Answer


