To get the value of selected radio button, a user-defined function can be created that gets all the radio buttons with the name attribute and finds the radio button selected using the checked property. The checked property returns True if the radio button is selected and False otherwise. If there are multiple Radio buttons in a webpage, first, all the input tags are fetched and then the values of all the tags that have type as ‘radio’ and are selected are displayed.
Example 1: The following program displays the value of selected radio button when user clicks on Submit button.
Example 2: The following program displays values of all the selected radio buttons when submit is clicked.
- How to know which radio button is selected using jQuery?
- How to create a radio button similar to toggle button using Bootstrap ?
- How to Create Custom Radio Button using HTML and CSS ?
- How to get selected text from a drop-down list using jQuery?
- How to get file input by selected file name without path using jQuery ?
- How to change selected value of a drop-down list using jQuery?
- How to reset selected value to default using jQuery ?
- Radio Button Vs Checkbox in HTML
- How to check a radio button with jQuery?
- How to get multiple selected values of select box in php?
- button tag vs input type="button" attribute
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.