File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes checkbox activated deactivated Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "checkbox activated deactivated" Watch "checkbox activated deactivated" New topic

checkbox activated deactivated

Isaac Ferguson
Ranch Hand

Joined: Jun 22, 2012
Posts: 752

I am retrieving from my servlet always true using the code

My html code is

But i want retrieve true only if the checkbox is pressed. Any idea?

Junilu Lacar

Joined: Feb 26, 2001
Posts: 6529

You are using the wrong attribute. Use checked="checked" in your markup to make it checked when the page is loaded. The value attribute is used to differentiate the checkbox from other checkboxes in the same group (that is, a group of checkboxes would have the same 'name' attribute but each checkbox would have a unique 'value' to differentiate it from others)

Junilu - [How to Ask Questions] [How to Answer Questions]
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63866

The value of the checkbox will only be submitted when it is checked. If unchecked, no value will be submitted.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: checkbox activated deactivated
It's not a secret anymore!