Questions tagged [radio-button]

Radio buttons are elements used in forms. They let a user select exactly one of a limited number of choices.

Radio buttons are a GUI element found in many types of forms, both on the web and in standalone applications, and they are used to let the user select one option out of a set of choices. It is often useful to provide some form of visual grouping around a collection of radio buttons so as to help the user see more clearly what they are picking between.

Where there is a binary choice, it can be better to use a instead. Some types of choices may be better suited to the use of a element or a element, though radio buttons have the advantage of allowing the user to see all the possible options (and often descriptions of them) at once, which enhances discoverability at a cost of occupying more screen space.

11983 questions
206
votes
7 answers

AngularJS - Binding radio buttons to models with boolean values

I am having a problem binding radio buttons to an object whose properties have boolean values. I am trying to display exam questions retrieved from a $resource. HTML:
185
votes
10 answers

Jquery If radio button is checked

Possible Duplicate: Check of specific radio button is checked I have these 2 radio buttons at the moment so that the user can decide whether they need postage included in the price or not:
Daniel H
  • 2,865
  • 8
  • 34
  • 32
176
votes
11 answers

Assign an initial value to radio button as checked

How do I assign the value of a radio button initially as checked in HTML?
RPB
  • 16,006
  • 16
  • 55
  • 79
175
votes
9 answers

jQuery $("#radioButton").change(...) not firing during de-selection

About a month ago Mitt’s question went unanswered. Sadly, I’m running into the same situation now. http://api.jquery.com/change/#comment-133939395 Here’s the situation: I’m using jQuery to capture the changes in a radio button. When the radio button…
antwarpes
  • 2,257
  • 2
  • 17
  • 18
151
votes
5 answers

What is the difference between formControlName and FormControl?

I'm using ReactiveFormsModule of Angular2 to create a component that contains a form. Here is my code: foo.component.ts: constructor(fb: FormBuilder) { this.myForm = fb.group({ 'fullname': ['', Validators.required], 'gender': [] …
148
votes
14 answers

jQuery set radio button

I am trying to set a radio button. I want set it by using the value or the id. This is what I've tried. $('input:radio[name=cols]'+" #"+newcol).attr('checked',true); newcol is the id of the radio button. Maybe a little edit is in order. There are…
mike628
  • 45,873
  • 18
  • 40
  • 57
148
votes
8 answers

How to set radio button checked as default in radiogroup?

I have created RadioGroup and RadioButton dynamically as following: RadioGroup radioGroup = new RadioGroup(context); RadioButton radioBtn1 = new RadioButton(context); RadioButton radioBtn2 = new…
Sandeep Kumar P K
  • 7,412
  • 6
  • 36
  • 40
145
votes
3 answers

Using "label for" on radio buttons

When using the "label for" parameter on radio buttons, to be 508 compliant*, is the following correct? or is this?
Wilkie
141
votes
8 answers

ASP.NET MVC Yes/No Radio Buttons with Strongly Bound Model MVC

Does anyone know how to bind a Yes/No radio button to a boolean property of a Strongly Typed Model in ASP.NET MVC. Model public class MyClass { public bool Blah { get; set; } } View <%@ Page Title="blah" Inherits="MyClass"%>
brianstewey
  • 1,792
  • 3
  • 14
  • 14
139
votes
7 answers

Check a radio button with javascript

For some reason, I can't seem to figure this out. I have some radio buttons in my html which toggles categories: // All
ptf
  • 3,210
  • 8
  • 34
  • 67
137
votes
15 answers

How to change the size of the radio button using CSS?

Is there a way to control the size of the radio button in CSS ?
Misha Moroshko
  • 166,356
  • 226
  • 505
  • 746
132
votes
17 answers

Angular2 - Radio Button Binding

I want to use radio button in a form using Angular 2 Options :
1 :
2 :
Mourad Zouabi
  • 2,187
  • 2
  • 15
  • 20
132
votes
14 answers

Which Radio button in the group is checked?

Using WinForms; Is there a better way to find the checked RadioButton for a group? It seems to me that the code below should not be necessary. When you check a different RadioButton then it knows which one to uncheck… so it should know which is…
Billy
  • 2,600
  • 6
  • 31
  • 36
131
votes
9 answers

How to set OnClickListener on a RadioButton in Android?

I have two RadioButtons inside a RadioGroup. I want to set OnClickListener on those RadioButtons. Depending on which RadioButton is clicked, I want to change the text of an EditText. How can I achieve this?
mayur rahatekar
  • 4,410
  • 12
  • 37
  • 51
113
votes
15 answers

How to vertically align a html radio button to its label?

I have a form with radio buttons that are on the same line as their labels. The radio buttons are however not aligned vertically with their labels as shown in the screenshot below. How can I vertically align the radio buttons with their…
ninjacoder
  • 1,464
  • 2
  • 10
  • 13