Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Struts
Search Coderanch
Advance search
Google search
Register / Login
Win a copy of
Cloud Application Architecture Patterns: Designing, Building, and Modernizing for the Cloud
this week in the
Cloud/Virtualization
forum!
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
paul wheaton
Paul Clapham
Ron McLeod
Sheriffs:
Jeanne Boyarsky
Liutauras Vilda
Saloon Keepers:
Tim Holloway
Carey Brown
Roland Mueller
Piet Souris
Bartenders:
Forum:
Struts
select all in list box
ben oliver
Ranch Hand
Posts: 375
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I have a
struts
2 list box, want to create button or link for "select all items" for user to click and select all the items in the list box. How to do that ? any example ?
Roberto Hernandez
Ranch Hand
Posts: 33
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I guess you'll have to do this with javascript. See this example.
First, make sure you give your listbox an id attribute;
function selectAll(){ var selectBox = document.getElementById("myList"); if(selectBox.length > 0){ //Select all options from the Select Box Element for(var i = 0; i < selectBox.options.length; i++){ selectBox.options[i].selected = true; } } }
Then, you can invoke this function when the user clicks on the button
<input type="button" value="Select All" onclick="selectAll();" />
Consider Paul's
rocket mass heater
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
re:selecting an option from a select box
adding a SelectItem object at particular index position in java.util.list
MULTIPLE select - list box - how to read in servlet
storing values chosen from dropdown
"Select Boxes" - Same Name
More...