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
3051
votes
40 answers

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
  • 80,295
  • 52
  • 162
  • 195
1022
votes
33 answers

How to check a radio button with jQuery?

I try to check a radio button with jQuery. Here's my code:
Alexis
  • 16,629
  • 17
  • 62
  • 107
881
votes
5 answers

How to select a radio button by default?

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?
jslearner
  • 21,331
  • 18
  • 37
  • 35
781
votes
33 answers

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 the form is generated. Here is the sample code of…
user1114212
  • 7,827
  • 2
  • 14
  • 3
577
votes
5 answers

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 field gets it?
nerdess
  • 10,051
  • 10
  • 45
  • 55
544
votes
16 answers

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(){ $(this).val(""); }); $('#frm…
systemsfault
  • 15,207
  • 12
  • 59
  • 66
470
votes
11 answers

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; set; } And I got three RadioButtons in my WPF…
Sam
  • 28,421
  • 49
  • 167
  • 247
447
votes
31 answers

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:
Fixed Rate Variable Rate …
ZombieBatman
  • 4,473
  • 3
  • 13
  • 4
377
votes
19 answers

How to get the selected radio button’s value?

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) and return it to a variable. For some reason it…
mkyong
  • 12,497
  • 12
  • 37
  • 56
353
votes
9 answers

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.
  • 3,549
  • 2
  • 16
  • 6
331
votes
18 answers

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

I have 3 radio buttons in my web page, like below:
331
votes
29 answers

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
  • 4,699
  • 10
  • 33
  • 32
326
votes
15 answers

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
  • 83,471
  • 91
  • 263
  • 383
263
votes
17 answers

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 it grays out the radio button. Read-only is really…
mcv
  • 4,217
  • 6
  • 34
  • 40
231
votes
27 answers

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
  • 11,309
  • 23
  • 92
  • 150
1
2 3
99 100