Questions tagged [radio-button]

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

Filter by
Sorted by
Tagged with
3066 votes
39 answers
2.5m views

How can I know which radio button is selected via jQuery?

I have two radio buttons and want to post the value of the selected one. How can I get the value with jQuery? I can get all of them like this: $("form :radio") How do I know which one is selected?
juan's user avatar
  • 81.1k
1028 votes
33 answers
1.8m views

How to check a radio button with jQuery?

I try to check a radio button with jQuery. Here's my code: <form> <div id='type'> <input type='radio' id='radio_1' name='type' value='1' /> <input type='radio'...
Alexis's user avatar
  • 16.7k
902 votes
5 answers
2.0m views

How to select a radio button by default? [duplicate]

I have some radio buttons and I want one of them to be set as selected by default when the page is loaded. How can I do that? <input type="radio" name="imgsel" value="" />
jslearner's user avatar
  • 21.8k
798 votes
33 answers
1.8m views

jQuery get value of selected radio button

The problem statement is simple. I need to see if user has selected a radio button from a radio group. Every radio button in the group share same id. The problem is that I don't have control on how ...
user1114212's user avatar
  • 7,997
597 votes
4 answers
697k views

How to use the "required" attribute with a "radio" input field

I am just wondering how to use the new HTML5 input attribute "required" in the right way on radio buttons. Does every radio button field need the attribute like below or is it sufficient if only one ...
nerdess's user avatar
  • 10.5k
549 votes
17 answers
914k views

How to uncheck a radio button?

I have group of radio buttons that I want to uncheck after an AJAX form is submitted using jQuery. I have the following function: function clearForm(){ $('#frm input[type="text"]').each(function(){ ...
systemsfault's user avatar
  • 15.3k
476 votes
11 answers
170k views

How to bind RadioButtons to an enum?

I've got an enum like this: public enum MyLovelyEnum { FirstSelection, TheOtherSelection, YetAnotherOne }; I got a property in my DataContext: public MyLovelyEnum VeryLovelyEnum { get; ...
Sam's user avatar
  • 28.7k
470 votes
27 answers
1.7m views

How to get the value of a selected radio button

I want to get the selected value from a group of radio buttons. Here's my HTML: <div id="rates"> <input type="radio" id="r1" name="rate" value="...
ZombieBatman's user avatar
  • 4,703
385 votes
20 answers
1.1m views

How to get the selected radio button’s value? [duplicate]

I’m having some strange problem with my JS program. I had this working properly but for some reason it’s no longer working. I just want to find the value of the radio button (which one is selected) ...
mkyong's user avatar
  • 12.7k
358 votes
9 answers
435k views

How do I group Windows Form radio buttons?

How can I group the radio buttons in Windows Form application (a lot like ASP.NET's radiobuttonlist!)? So I can switch between each case chosen from the options.
MW.'s user avatar
  • 3,599
335 votes
30 answers
1.4m views

How can I check whether a radio button is selected with JavaScript?

I have two radio buttons within an HTML form. A dialog box appears when one of the fields is null. How can I check whether a radio button is selected?
noob's user avatar
  • 4,749
333 votes
18 answers
569k views

In jQuery, how do I select an element by its name attribute?

I have 3 radio buttons in my web page, like below: <label for="theme-grey"> <input type="radio" id="theme-grey" name="theme" value="grey" />Grey</label> <label for="theme-...
djmzfKnm's user avatar
  • 27k
327 votes
15 answers
738k views

how to set radio option checked onload with jQuery

How to set radio option checked onload with jQuery? Need to check if no default is set and then set a default
Phill Pafford's user avatar
267 votes
17 answers
359k views

Why can't radio buttons be "readonly"?

I would like to show a radio button, have its value submitted, but depending on the circumstances, have it not editable. Disabled doesn't work, because it doesn't submit the value (or does it?), and ...
mcv's user avatar
  • 4,287
244 votes
27 answers
748k views

How do I change the color of radio buttons?

I mean, a radio button itself consists of a round shape and a dot at the center (when the button is selected). What I want to change is the color of both. Can this be done using CSS?
catandmouse's user avatar
  • 11.7k
206 votes
7 answers
229k views

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: <label data-ng-repeat="...
peteallen's user avatar
  • 2,553
187 votes
10 answers
497k views

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's user avatar
  • 2,915
181 votes
11 answers
231k views

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's user avatar
  • 16.2k
177 votes
9 answers
358k views

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 ...
antwarpes's user avatar
  • 2,277
158 votes
5 answers
141k views

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'...
smartmouse's user avatar
151 votes
8 answers
197k views

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); ...
Sandeep Kumar P K's user avatar
149 votes
14 answers
315k views

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 ...
mike628's user avatar
  • 47.9k
147 votes
3 answers
210k views

Using "label for" on radio buttons

When using the "label for" parameter on radio buttons, to be 508 compliant*, is the following correct? <label for="button one"><input type="radio" name="group1" id="r1" value="1" /> ...
user avatar
144 votes
7 answers
521k views

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: <input type="radio" name="main-categories" id="_1234" value="1234" /> // All &...
ptf's user avatar
  • 3,270
143 votes
15 answers
455k views

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's user avatar
141 votes
8 answers
153k views

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 <%@ ...
brianstewey's user avatar
  • 1,792
134 votes
17 answers
301k views

Angular2 - Radio Button Binding

I want to use radio button in a form using Angular 2 Options : <br/> 1 : <input name="options" ng-control="options" type="radio" value="1" [(ng-model)]="model.options" ><br/> 2 :...
Mourad Zouabi's user avatar
132 votes
14 answers
361k views

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 ...
Billy's user avatar
  • 2,600
131 votes
9 answers
238k views

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 ...
mayur rahatekar's user avatar
115 votes
15 answers
226k views

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 ...
ninjacoder's user avatar
  • 1,484
110 votes
5 answers
119k views

Can you tab through all radio buttons?

I have a list of radio buttons. when I tab through them, seems like only the first radio button or the one that is selected will get focused, the rest of the radio buttons will get skipped. checkbox ...
qinking126's user avatar
  • 11.7k
109 votes
21 answers
276k views

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 ...
Vannian's user avatar
  • 1,520
104 votes
19 answers
91k views

Add margin between a RadioButton and its label in Android?

Is it possible to add a little bit of space between a RadioButton and the label while still using Android's built-in components? By default the text looks a little scrunched. <RadioButton android:...
allclaws's user avatar
  • 5,665
103 votes
6 answers
117k views

Is it possible to change the radio button icon in an android radio button group

I am wanting to allow the user of my android application the ability to set some parameters. The radio button is ideal for this situation. However, I don't like the radio buttons are rendered. Is ...
yamspog's user avatar
  • 18.3k
103 votes
31 answers
352k views

How to make a radio button unchecked by clicking it?

Unlike check boxes, it is impossible for the user to deselect radio buttons once they are clicked. Is there any way so that they can be toggled programmatically using Javascript? This would be ...
Student's user avatar
  • 1,157
103 votes
21 answers
52k views

How to group RadioButton from different LinearLayouts?

I was wondering if is possible to group each single RadioButton in a unique RadioGroup maintaining the same structure. My structure look like this: LinearLayout_main LinearLayout_1 RadioButton1 ...
marcoqf73's user avatar
  • 1,324
100 votes
4 answers
111k views

Toggle HTML radio button by clicking its label

Is there please a simple way to make a radio button toggle - when a text near it is clicked - without introducing any big Javascript Framework into my smal PHP project? The web form looks like this: ...
Alexander Farber's user avatar
97 votes
7 answers
123k views

Clicking the text to select corresponding radio button

I'm creating a quiz web application using PHP. Each question is comprised of a separate <label> and has 4 possible choices, using radio buttons to allow the user to select his/her answer. The ...
Abundnce10's user avatar
  • 2,190
97 votes
5 answers
106k views

JQuery - find a radio button by value

How would I use JQuery to find a radio button by its value?
van's user avatar
  • 9,379
94 votes
9 answers
235k views

Checking Value of Radio Button Group via JQUERY?

This may seem silly and downright stupid but I can't seem to figure out how to check the value of a radio button group in my HTML form via JavaScript. I have the following code: <input type="radio"...
Propeller's user avatar
  • 2,503
88 votes
15 answers
263k views

Radio Buttons "Checked" Attribute Not Working

The radio button does not show up as checked by default. I started off without a default choice doing some very simple js validation and it wasn't working. So I opted to just use default values until ...
Jordan's user avatar
  • 881
88 votes
5 answers
210k views

click or change event on radio using jquery

I have some radios in my page,and I want to do something when the checked radio changes,however the code does not work in IE: $('input:radio').change(...); And after googling,people suggest use the ...
hguser's user avatar
  • 35.6k
86 votes
11 answers
247k views

How to check if a radiobutton is checked in a radiogroup in Android?

I need to set validation that user must fill / select all details in a page. If any fields are empty wanna show Toast message to fill. Now I need set validation for RadioButton in the RadioGroup. I ...
Srihari's user avatar
  • 2,419
84 votes
3 answers
96k views

get value from radio group using jquery

I am trying to get value of radio group with name managerelradio. My html code for this radio group is. <label><input type="radio" name="managerelradio" value="Yes" id="Add">Add</...
Rahul Singh's user avatar
  • 1,636
81 votes
10 answers
155k views

Simple WPF RadioButton Binding?

What is the simplest way to bind a group of 3 radiobuttons to a property of type int for values 1, 2, or 3?
Johnathan1's user avatar
  • 2,281
79 votes
13 answers
266k views

Radio/checkbox alignment in HTML/CSS

What is the cleanest way to align properly radio buttons / checkboxes with text? The only reliable solution which I have been using so far is table based: <table> <tr> <td><...
Jan Zich's user avatar
  • 15.2k
78 votes
4 answers
119k views

Android:placing the radio buttons horizontally

Below is my Relative layout..i am trying to place the radio buttons above the edittext <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/...
teekib's user avatar
  • 2,821
78 votes
1 answer
124k views

Get Value of Radio button group

I'm trying to get the value of two radio button groups using the jQuery syntax as given below. When the code below is run I get the value selected from the first radio button group twice instead of ...
Parampal Pooni's user avatar
75 votes
9 answers
161k views

How to set a radio button in Android

I have an app that uses radio buttons. The default for this button is set in the main.xml file, ie: android:id="@+id/rb_sat1E" android:checked="true" In the Java file I have: final RadioButton ...
Entropy1024's user avatar
  • 7,893
75 votes
9 answers
167k views

How to make a radio button look like a toggle button

I want a group of radio buttons to look like a group of toggle buttons (but still function like radio buttons). It's not necessary that they look exactly like toggle buttons. How can I do this only ...
Pomber's user avatar
  • 1,165

1
2 3 4 5
241