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
148
votes
17 answers

Angular ReactiveForms: Producing an array of checkbox values?

Given a list of checkboxes bound to the same formControlName, how can I produce an array of checkbox values bound to the formControl, rather than simply true/false? Example:
marked-down
  • 9,958
  • 22
  • 87
  • 150
145
votes
12 answers

How to uncheck checkbox using jQuery Uniform library

I have a problem with unchecking a checkbox. Have a look at my jsFiddle, where I am attempting: $("#check2").attr("checked", true); I use uniform for styling the checkbox and it simply does not work to check/uncheck the checkbox. Any ideas?
DarkLeafyGreen
  • 69,338
  • 131
  • 383
  • 601
145
votes
7 answers

Checkboxes in web pages – how to make them bigger?

The standard checkboxes rendered in most browsers are quite small and don’t increase in size even when a larger font is used. What is the best, browser-independent way to display larger checkboxes?
Tony the Pony
  • 40,327
  • 71
  • 187
  • 281
133
votes
9 answers

How to set True as default value for BooleanField on Django?

I'm using BooleanField in Django. By default, the checkbox generated by it is unchecked state. I want the state to be checked by default. How do I do that?
Bin Chen
  • 61,507
  • 53
  • 142
  • 183
127
votes
16 answers

How can I distinguish whether Switch,Checkbox Value is changed by user or programmatically (including by retention)?

setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // How to check whether the checkbox/switch has been checked …
Solvek
  • 5,158
  • 5
  • 41
  • 64
127
votes
11 answers

if checkbox is checked, do this

When I check a checkbox, I want it to turn

#0099ff. When I uncheck the checkbox, I want it to undo that. Code I have so far: $('#checkbox').click(function(){ if ($('#checkbox').attr('checked')) { /* NOT SURE WHAT TO DO HERE */ …

android.nick
  • 11,069
  • 23
  • 77
  • 112
124
votes
16 answers

Why cannot change checkbox color whatever I do?

I try to style checkbox background color, but it won't change whatever I do. I am using firefox 29 latest. Is there some rule changes in css or may be in the browser? CSS: input[type="checkbox"] { background: #990000; } .chk { …
Ari
  • 4,643
  • 5
  • 36
  • 52
115
votes
7 answers

How to handle change of checkbox using jQuery?

I have some code

BILL
  • 4,711
  • 10
  • 57
  • 96
115
votes
6 answers

How do I make a checkbox required on an ASP.NET form?

I've done some searching on this, and I've found several partial answers, however nothing that gives me that warm fuzzy "this is the right way to do this". To answer the most frequently occurring complaint against this question: "checkboxes can have…
Bob Kaufman
  • 12,864
  • 16
  • 78
  • 107
113
votes
13 answers

Android: How to change CheckBox size?

I would like to make CheckBox a bit smaller/bigger, how can I do this?
alex2k8
  • 42,496
  • 57
  • 170
  • 221
108
votes
20 answers

How to create radio buttons and checkbox in swift (iOS)?

I am developing an app that allows to do survey. My layout is generated from XML based questions. I need to create radio buttons (single choice) and checkboxes (multiple answers). I did not find anything useful for swift. Does anyone have an idea?
Vannian
  • 1,490
  • 5
  • 14
  • 26
99
votes
14 answers

How to reset all checkboxes using jQuery or pure JS?

How can I reset all checkboxes in a document using jQuery or pure JS?
streetparade
  • 32,000
  • 37
  • 101
  • 123
96
votes
13 answers

jQuery, checkboxes and .is(":checked")

When I bind a function to a checkbox element like: $("#myCheckbox").click( function() { alert($(this).is(":checked")); }); The checkbox changes its checked attribute before the event is triggered, this is the normal behavior, and gives an…
Ben
  • 16,275
  • 9
  • 45
  • 63
95
votes
1 answer

JQuery: if div is visible

I'm using JS as a way of changing the content of an SPA I'm creating. When I press a button to change the content the HTML changes from this:
95
votes
7 answers

How to check in js that user has checked the checkbox in Google recaptcha?

I have added the following before end of head I have added this before end of form
I can see the recaptcha similar to…
Hello Universe
  • 3,248
  • 7
  • 50
  • 86