Introduction:
Using Jquery we can get
selected value of Radiobutton list by name of radio button list. This can be
done by using server side code but using jquery it is fast and easy to
implement.
In this article I will explain how to use jQuery to get selected value of Radiobutton by name.
In this article I will explain how to use jQuery to get selected value of Radiobutton by name.
The following Method is used to
get selected value of radiobutton list by name of radio button list.
var selval = $('input[name=rdbcountry]:checked').val();
Full Source Code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery Get Selected Radio button
list value with name</title>
<script type="text/javascript"
src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
$(function
() {
$('#btnSubmit').click(function () {
var
selval = $('input[name=rdbName]:checked').val();
alert(selval)
})
});
</script>
</head>
<body>
<fieldset style="width:300px">
<legend><strong>Get Radio
Button value Using jquery</strong></legend> <br /><br />
<b>Select Radio Button :</b><br />
<input type="radio"
name="rdbName"
value="Ashish"
/>Ashish<br />
<input type="radio"
name="rdbName"
value="Anil"
/>Anil<br />
<input type="radio"
name="rdbName"
value="Ankush"
/>Ankush<br />
<button id="btnSubmit">Get
Selected Country</button>
<br /><br
/></fieldset>
</body>
</html>
0 comments:
Post a Comment