Questions tagged [checkbox]

A checkbox is a graphical user interface element that permits the user to make a binary selection.

A checkbox is a graphical user interface element that permits the user to make a binary selection. Checkboxes are often shown on the screen as a square box that can contain white space (for false) or a tick mark or X (for true). A caption describing the meaning of the checkbox is normally shown adjacent to the checkbox. Inverting the state of a checkbox is done by clicking the mouse on the box, or the caption, or by using a keyboard shortcut, such as the space bar.

Source: http://en.wikipedia.org/wiki/Checkbox


Some applications optionally allow a third state of Null, usually indicated by a grayed-out appearance. A similar provision is often made for a new record which has no instantiated values.

Here is an example of HTML code to present a checkbox in a user-entry form:

<input type="checkbox" name="example" value="foo">foo
  • The checked attribute is a boolean attribute.
  • When present, it specifies that an element should be pre-selected (checked) when the page loads.
  • The checked attribute can be used with <input type="checkbox"> and <input type="radio">.
  • The checked attribute can also be set after the page load, with a JavaScript.
29830 questions
94
votes
5 answers

Loop through checkboxes and count each one checked or unchecked

I've run into a bit of an issue. Here's a brief explanation. I have 12 check boxes on a standard form. What I need to do is loop through each of them and learn which ones are checked and which ones are unchecked. Using this, I can then build a…
Richard M
  • 1,445
  • 2
  • 13
  • 20
93
votes
9 answers

Why does the checkbox stay checked when reloading the page?

I'm reloading a web page that has the following code: Even though the HTML stays sent to the browser is the same for each reload of the…
readonly
  • 343,444
  • 107
  • 203
  • 205
91
votes
5 answers

How to check CheckListBox item with single click?

I am coding Windows Forms application in C# and using CheckListBox Control. How to check CheckListBox item with just single click?
Pratik Deoghare
  • 35,497
  • 30
  • 100
  • 146
90
votes
7 answers

WPF checkbox binding

While it is trivial to store a checkbox's checked state in a variable using the checkbox's Click event, how would I do it via databinding? All the examples I have found have the UI updated from some datasource, or bind one control to another; I…
Number8
  • 12,322
  • 10
  • 44
  • 69
90
votes
7 answers

How to trigger checkbox click event even if it's checked through Javascript code?

I have many checkboxes in my page and there is a select all checkbox which checks all the checkboxes. Somehow I want to emulate that click event of checkbox even if it's checked/unchecked through select all button. How can I do it?
Jishnu A P
  • 14,202
  • 8
  • 40
  • 50
90
votes
6 answers

Checkbox value is always 'on'

this is my checkbox HTML JQuery var eu_want_team = $('#eu_want_team').val(); alert(eu_want_team); Its always displaying ON, is it checked or not.…
user2705406
86
votes
3 answers

Possible to associate label with checkbox without using "for=id"?

I know that it is good sometimes to associate a label with a checkbox: ..but do I have to use an id to associate it? The main reason I even…
D.Tate
  • 2,289
  • 3
  • 22
  • 35
86
votes
8 answers

How do you tell if a checkbox is selected in Selenium for Java?

I am using Selenium in Java to test the checking of a checkbox in a webapp. Here's the code: private boolean isChecked; private WebElement e; I declare e and assign it to the area where the checkbox is. isChecked =…
jamesfzhang
  • 4,403
  • 8
  • 32
  • 43
86
votes
6 answers

What values for checked and selected are false?

I think according to W3 spec, you're supposed to do And selected="selected" But, most browsers will accept it you just write "CHECKED" and don't give it a value. So, what if you do include the…
mpen
  • 272,448
  • 266
  • 850
  • 1,236
86
votes
7 answers

How to remove padding around Android CheckBox

I need to put check to the right hand top corner of my imageview. But when I do this I noticed a default margin around my checkbox. Is there a way to remove this??
Lincy
  • 1,033
  • 1
  • 8
  • 14
85
votes
10 answers

Clicking a checkbox with ng-click does not update the model

Clicking on a checkbox and calling ng-click: the model is not updated before ng-click kicks in so the checkbox value is wrongly presented in the UI: This works in AngularJS 1.0.7 and seems broken in Angualar 1.2-RCx.
supercobra
  • 15,810
  • 9
  • 45
  • 51
84
votes
9 answers

What is the proper way to check and uncheck a checkbox in HTML5?

Looked at the HTML spec, but couldn't make heads or tails of it: http://www.w3.org/TR/html5/the-input-element.html#attr-input-checked What is the correct way to check a checkbox in HTML (not dynamically)? checked="true" checked="checked" What is…
B Seven
  • 44,484
  • 66
  • 240
  • 385
84
votes
9 answers

OnClick vs OnClientClick for an asp:CheckBox?

Does anyone know why a client-side javascript handler for asp:CheckBox needs to be an OnClick="" attribute rather than an OnClientClick="" attribute, as for asp:Button? For example, this works:
Stobor
  • 44,246
  • 6
  • 66
  • 69
81
votes
4 answers

Pure CSS checkbox image replacement

I've got a checkbox list in a table. (one of a number of CB's on the row)
Alex C
  • 16,624
  • 18
  • 66
  • 98
80
votes
10 answers

How can I change the size of a Bootstrap checkbox?

Wondering if its possible to change the size of checkbox as it's possible with buttons. I want it to be bigger, so it makes it easy to press. Right now its looking like this: Code: