Get Value of Selected Radio Button JavaScript


Get Value of Selected Radio Button JavaScript

Accessing radio button value in javascript

In this blog post, I will demonstrate how to get the checked value of radio button in javascript. Find the javascript code snippet below :- 
form radio button,  html5 radio button,  radio button onclick, html radio checked, radio buttons html,
getting values from radio button in html -
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
    <title>html radio button selected value javascript</title>

    <script type="text/javascript">
    function getSelectedRadioButtonValue() {
            var ctr = 0;
            var radiodbtn=document.getElementsByName("radiodbtn");
            var radioLength = radiodbtn.length;
            for (var i = 0; i < radioLength; i++) {
                if (radiodbtn[i].checked) {
            if (ctr == radioLength)
                alert("None of the category has been selected:");

    <form id="form1" runat="server">
    <div style="border: 10px; border-color: Gray;">
        <table cellspacing="15">
                <td valign="top">
                    <asp:Label ID="Label1" runat="server" Text="Select Category"></asp:Label>
                    <input type="radio" value="ASP.Net" name="radiodbtn" />ASP.Net
                    <input type="radio" value="C#" name="radiodbtn" />C#
                    <input type="radio" value="Google Maps" name="radiodbtn" />Google Maps
                    <input type="radio" value="MVC4" name="radiodbtn" />MVC4
                    <input type="radio" value="Entity Framework" name="radiodbtn" />Entity Framework
                    <input type="button" value="Get Value" onclick="getSelectedRadioButtonValue()" />
Get Value of Selected Radio Button JavaScript Reviewed by Ravi Kumar on 4:44 PM Rating: 5

No comments:

All Rights Reserved by Etechpulse © 2012 - 2017

Contact Form


Email *

Message *

Powered by Blogger.