This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes How to get Names of selected checkboxes? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to get Names of selected checkboxes?" Watch "How to get Names of selected checkboxes?" New topic
Author

How to get Names of selected checkboxes?

Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Hi..
I want to know that how we can get names of selected checkboxes?

Thanks


Life is easy because we write the source code.....
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

The names of the selected checkboxes will be submitted as request parameters with the value assigned to each checkbox.

Non-selected checkboxes will not be passed at all.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Hello Sir, Thanks for quick reply,

I have following html file in which user can select checkboes




and I have following Servlet class



Now when I hit the Url I get Output as from which department I had selected the book . Now I want to print the name of book also How I can do this in servlet .

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

Your HTML is incomplete. The checkboxes have no value attributes to distinguish between them.
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

oh yes

This is my new HTML file

Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Thank You Sir, because of incomplete Html code I had not getting the name of the book But now I got it.

Thanks again.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to get Names of selected checkboxes?
 
Similar Threads
req.getParameterValues returning null
Fetching checked data from html:checkbox inside logic:iterate
how to get selected check box values in struts?
how checkbox works in servlets?
getParameterMap and unselected checkboxes