wood burning stoves
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 Java Interview Guide this week in the Jobs Discussion 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.
I agree. Here's the link: http://aspose.com/file-tools
subject: how to retain selected value.....
It's not a secret anymore!