aspose file tools*
The moose likes JSP and the fly likes How to get multi-select to display Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How to get multi-select to display "selected" values when return to jsp page?" Watch "How to get multi-select to display "selected" values when return to jsp page?" New topic
Author

How to get multi-select to display "selected" values when return to jsp page?

Rod McLure
Greenhorn

Joined: Mar 04, 2010
Posts: 24
I have no problem selecting multiple values and saving them to the database, but I can't figure out how to "highlight" the values that were selected when I return to the jsp page. I would also like to display a string below the select box listing the values ie ${ordTyp.description } that were in the database. Thank you
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61180
    
  66

Add the selected attribute to the options that you want to pre-select. You'll need to pass the previous selections so that you can re-select them using this mechanism.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rod McLure
Greenhorn

Joined: Mar 04, 2010
Posts: 24
thanks for the quick response I am looping through all the possible values for each database value selected, if there is a match I want to set mySelectVar to selected
I have not used expression language very much , so I'm guessing there is something wrong with my syntax.

here for each option I would indicate if it was selected or not
<option value="${ordTyp.id}" ${(mySelectVar eq 'selected')?'selected' : ''}>${ordTyp.description}</option>

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61180
    
  66

I see nothing wrong with the syntax. Time to check values to see if they're really what you think they are.
Rod McLure
Greenhorn

Joined: Mar 04, 2010
Posts: 24
I'm sooo! sorry to waste your time. I tried working on displaying just the list of selected, and I found I was using the wrong fieldname.
Thank you
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61180
    
  66

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get multi-select to display "selected" values when return to jsp page?