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 JSP and the fly likes how to retain selected value..... 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 » Java » JSP
Bookmark "how to retain selected value....." Watch "how to retain selected value....." New topic

how to retain selected value.....

reddy kl

Joined: Apr 04, 2002
Posts: 11
Hi all
i have two listboxes and when i selected one item in first listbox and submitting the form,am getting the items in next listbox according the item selected in the first listbox from the database.but the item which i selected in first listbox is not appearing but taking the default value...
how to retain that item..plz note that the items in first listbox are also from database...
can any one help me out with code snippet..
thanks in advance..
mahadev ramalingam

Joined: Jan 15, 2002
Posts: 12
place the selected value or index in a hidden text box or in a variable and then assign it to the select box using javascript. this gets selected when the values come from the d/b into the second select box.
Hope this helps u.
Prashanth menon
Ranch Hand

Joined: Feb 20, 2001
Posts: 65
Hi devender
As I can understand you submit from first page having a listbox(first) , you have to get this in the second page which has second listbox with the current selected value as the one you just selected.
try this in second jsp

I thing this is what you wanted.
Consider Paul's rocket mass heater.
subject: how to retain selected value.....
Similar Threads
Create dropdown listbox menu Using JSP and AJAX control
Spin through listbox items and update selection status
MULTIPLE select - list box - how to read in servlet
retrieving list (multiple select on the form) values into servlet!!!