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
234
votes
8 answers

Find all unchecked checkboxes in jQuery

I have a list of checkboxes: ... I can collect all the values of…
Gary
  • 4,495
  • 13
  • 36
  • 49
232
votes
17 answers

Using the HTML5 "required" attribute for a group of checkboxes?

When using the newer browsers that support HTML5 (FireFox 4 for example); and a form field has the attribute required='required'; and the form field is empty/blank; and the submit button is clicked; the browsers detects that the "required" field is…
Zabba
  • 64,285
  • 47
  • 179
  • 207
218
votes
10 answers

Javascript checkbox onChange

I have a checkbox in a form and I'd like it to work according to following scenario: if someone checks it, the value of a textfield (totalCost) should be set to 10. then, if I go back and uncheck it, a function calculate() sets the value of…
bikey77
  • 6,384
  • 20
  • 60
  • 86
218
votes
13 answers

Do checkbox inputs only post data if they're checked?

Is it standard behaviour for browsers to only send the checkbox input value data if it is checked upon form submission? And if no value data is supplied, is the default value always "on"? Assuming the above is correct, is this consistent behaviour…
Mark
  • 2,669
  • 2
  • 17
  • 13
206
votes
9 answers

How to stop event bubbling on checkbox click

I have a checkbox that I want to perform some Ajax action on the click event, however the checkbox is also inside a container with its own click behaviour that I don't want to run when the checkbox is clicked. This sample illustrates what I want to…
roryf
  • 29,592
  • 16
  • 81
  • 103
203
votes
8 answers

React Checkbox not sending onChange

TLDR: Use defaultChecked instead of checked, working jsbin. Trying to setup a simple checkbox that will cross out its label text when it is checked. For some reason handleChange is not getting fired when I use the component. Can anyone explain…
jdarling
  • 2,438
  • 2
  • 14
  • 10
195
votes
18 answers

Tri-state Check box in HTML?

There is no way to have a tri-state check button (yes, no, null) in HTML, right? Are there any simple tricks or work-arounds without having to render the whole thing by oneself?
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
193
votes
12 answers

Custom checkbox image android

Is there an easy way to use a custom image for a checkbox? I'm looking to duplicate the "starred" behavior of gmail. So I want to have a checkbox that, when checked, is a filled in star. And when unchecked is an empty star. Do I have to use an…
Falmarri
  • 47,727
  • 41
  • 151
  • 191
188
votes
21 answers

Change Checkbox value without triggering onCheckChanged

I have setOnCheckedChangeListener implemented for my checkbox Is there a way I can call checkbox.setChecked(false); without triggering the onCheckedChanged
Archie.bpgc
  • 23,812
  • 38
  • 150
  • 226
180
votes
26 answers

How do I check/uncheck all checkboxes with a button using jQuery?

I am trying to check/uncheck all checkboxes using jQuery. Now by checking/unchecking the parent checkbox all the child checkboxes are getting selected/deselected also with the text of parent checkbox getting changed to checkall/uncheckall. Now I…
Ravi
  • 4,015
  • 7
  • 30
  • 35
176
votes
5 answers

Get $_POST from multiple checkboxes

I have 1 form in with multiple checkboxes in it (each with the code): Where $row['Report ID'] is a primary key in a database -so each value is different. How would I be…
James Andrew
  • 7,197
  • 14
  • 46
  • 62
174
votes
16 answers

How to show android checkbox at right side?

By default android checkbox shows text at right side and checkbox at left I want to show checkbox at right side with text at left how do I achieve this?
UMAR-MOBITSOLUTIONS
  • 77,236
  • 95
  • 209
  • 278
168
votes
27 answers

How to check all checkboxes using jQuery?

I am not expert with jQuery but I have tried to create a little script for my application. I want to check all checkboxes but it isn't working correctly. First I tried to use attr and after that I tried with prop but I'm doing something wrong. I…
Ivan
  • 5,139
  • 11
  • 53
  • 86
164
votes
19 answers

html select only one checkbox in a group

So how can I only allow a user to select only one checkbox? I know radio buttons are "ideal", but for my purpose...it's not. I have a field where users need to select either or of the two options, but not both. The problem is that I need my users to…
user962449
  • 3,743
  • 9
  • 38
  • 53
156
votes
7 answers

jQuery checkbox event handling

I have the following:
How do I use jQuery to capture any check event occuring in myform and tell which…
aeq
  • 10,377
  • 15
  • 45
  • 46