I have a JSP which includes 2 select lists. The option selected from the first select list determines which set of options is displayed in the second select list.
The first select list always consists of the same, few options whereas the second select list's options may be numerous and importantly, are dynamic not only in terms of option list dependancy on the first select list but also because the values that make up each possible set of option values for the second select list are based on editable database values and therefore may change.
Currently, when I select an option from the first select list, I submit and reload the page to send through the selected option as a request parameter and use it to set a pageContext attribute in the reloaded page. I then test this pageContext attribute against several 'if' conditions to identify which is the correct set of options to display for the second select list. Then, I iterate through the set of values of the session-scoped attribute which applies to the matched 'if' condition. The session-scoped attribute holds a set of values retrieved from the database which are finally written out to the page as the second select list's option values.
My question is this: is there a way to display the relevant options for the second select list without reloading the page?
The actual code is proprietary and I can't give it to you but the principle isn't that difficult.
Joined: Oct 04, 2004
Thank you very much Daniel and Jeroen. Daniel, I found the article you attached to be very helpful and am currently experimenting with the remote scripting methods discussed as a possible solution to my problem.
The principle of what Jeroen suggests is encompassed by the remote scripting concept.
subject: Populating a dependant select list without reloading the page