Get your CodeRanch badge!*
The moose likes Struts and the fly likes How to Highlight (select) all elements of a Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to Highlight (select) all elements of a "multiple select" when the page loads?" Watch "How to Highlight (select) all elements of a "multiple select" when the page loads?" New topic
Author

How to Highlight (select) all elements of a "multiple select" when the page loads?

Johnny Brown
Greenhorn

Joined: Jul 27, 2009
Posts: 10
Gurus,
I am trying to use a multiple select. Data comes correct and the box gets populated properly. However, no value gets selected when the page gets loaded first time.
How do I make all elements of that box get selected by default? Following is the piece of code.

Appreciate any help.

Thanks.

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Is the ActionForm properly initialized?
Venkata Kumar
Ranch Hand

Joined: Apr 16, 2008
Posts: 110

In the actionform initialize the array productIdSelected with all the option elements. When the page is rendered the option values that match with productIdSelected values are pre selected.


SCJP 5.0, SCWCD 5, preparing for SCDJWS
Johnny Brown
Greenhorn

Joined: Jul 27, 2009
Posts: 10
Wow..
That was quick.

It worked!

Thank you, Venkat and David.

Venkat Divvela wrote:In the actionform initialize the array productIdSelected with all the option elements. When the page is rendered the option values that match with productIdSelected values are pre selected.


Is the ActionForm properly initialized?


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to Highlight (select) all elements of a "multiple select" when the page loads?
 
Similar Threads
Using html:select with string arrays
2-dimentional array
How to use multiple attribute on html:select struts tag
In List Highlighting previous selected values
Access all items in Select Box.