Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

How to Get Radio button Selected Value in jQuery

Mar 23, 2014
Introduction

Here I will explain how to get radio button value in
jQuery or get radio button checked value in jQuery with example or get radio button selected value in jQuery.

Description:
  
In previous articles I explained
jQuery expand textbox on focus, jQuery disable right click on image, jQuery print div content with cs using jquery print plugin and many articles related to jQuery. Now I will explain how to get radio button checked value in jQuery with example.

To get radio button selected value we need to write the code like as shown below


<script type="text/javascript">
function GetAge() {
var selctedval = $('input[name=rdbage]:checked').val();
alert(selctedval);
}
</script>
If you want complete example we need to write the code like as shown below


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery get radio button selected value</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript">
function GetAge() {
var selctedval = $('input[name=rdbage]:checked').val();
if (selctedval != '' && typeof selctedval != 'undefined') {
alert('You Selected '+selctedval+' Age Group');
}
else {
alert('Please Select Age Group')
}
}
</script>
</head>
<body>
<form id="form1">
<div>
<b>Select Age Group:</b>
<input type="radio" name="rdbage" value="10 - 15 Years" /> 10 - 15 Years
<input type="radio" name="rdbage" value="15 - 30 Years" /> 15 - 30 Years
<input type="radio" name="rdbage" value="30 - 50 Years" /> 30 - 50 Years<br/><br/>
<input type="button" id="btnGetAge" value="Get Age Group" onclick="GetAge()" />
</div>
</form>
</body>
</html>
Live Demo

If you want to check live demo click on below button


Select Age Group: 10 - 15 Years 15 - 30 Years 30 - 50 Years




If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

0 comments :

Give your Valuable Comments

Other Related Posts

© 2010-2012 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.