I have two combo boxes in my JSP page named combo1 and combo2. I have a table in mysql called ZoneData. In this table there are two columns called zone and subzone. When the web page loads I want that when I select a zone name from combo1, all subzones of the selected zone should be extracted from ZoneData table and added in combo2. I am unable to do this. Should I use any combo1’s event. Please help I am a newbie in web programming.
Share
The usual way to do this type of things is to use javascript to manage combo1 onChange event.
I recommend you to use jQuery framework, as it eases a lot the basics of javascript client coding http://jquery.com
What you do when the event is fired is to capture it on a javascript function and make an AJAX call to your server, where you have some server method to filter the combo2 values that has to be loaded into your combo2 depending on the value of combo1. When this method returns, the AJAX call will receive the values from the method and will allow you to update data in combo2
This is a brief example of the jQuery code you’ll need to manage the change event and make the AJAX call: