Hi Guys,
A very simple problem in jsp. i want to populate a second drop down list upon selection value of first drop down list . how can i do this in jsp.upon the selection of value from first drop down the parameter will be passed to a sql query that takes this parameter and the resulting rows will be populated in second drop down. what is the mature logic to do this without using ajax. |
I'd do this client-side using JavaScript by loading all the possible values into a set of arrays or name/value pairs. Then stick an onchange event on the first drop down to repopulate the second drop down.
Of course, you don't want to rely on Javascript firing, so you should check your submission server-side too to make sure it validates. If the value isn't valid, you'll have reloaded the page by that time, so you can repopulate the second drop down using the query server side based on the submitted value for the first drop down. |
Hi Tony,
Thanks for the logic, I thought of doing with two forms elements and storing the state in hidden fields. |