You can use jQuery / JavaScript to get the selected value of a RadioButtonList . jQuery provides much more simpler approach as shown below.
jQuery
var selectedVal = $('#<%= RadioButtonList.ClientID %> input:checked').val();
JavaScript
var radioList= document.getElementById("<%= RadioButtonList.ClientID %>");
var options= radioList.getElementsByTagName("input");
var selected;
for (var i = 0; i < options.length; i++) {
if (options[i].checked) {
selected = options[i];
break;
}
}
if (selected) {
alert(selected.value);
}
Regards,
Samitha
jQuery
var selectedVal = $('#<%= RadioButtonList.ClientID %> input:checked').val();
JavaScript
var radioList= document.getElementById("<%= RadioButtonList.ClientID %>");
var options= radioList.getElementsByTagName("input");
var selected;
for (var i = 0; i < options.length; i++) {
if (options[i].checked) {
selected = options[i];
break;
}
}
if (selected) {
alert(selected.value);
}
Regards,
Samitha
No comments:
Post a Comment