jQuery in Action, 3rd edition
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

Win a copy of REST with Spring (video course) this week in the Spring forum!
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: 649

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: 6521

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: 63548

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: http://aspose.com/file-tools
subject: checkbox activated deactivated
It's not a secret anymore!