Getting ASP.NET Radiobutton list Text using javascript not JQuery
I came accross a problem while I was trying to Get ASP.NET Radiobutton list Text using JQuery.
I used the JQuery method
$(‘#<%=RadioButtonList1.ClientID%>’).val();
but it was not returning selected value though same works for asp.net Dropdown list then I started searching over the internet but didn’t find any solution.
After searching for an hour I started looking for classic javascript to get the text of selected item in the Radio button list,
but all of the examples were giving me value of the selected item in the radio button list.
Onec I was struggling to get the text of selected item in asp.net dropdown list then found a solution which you can see in my post here
by combining the logic of this disablingenabling-aspnet-checkboxlist-items-using-javascritp
post with the code below I was able to find a solution to my problem.
Following code will give you the text of selected Item in an asp.net radio button list same also is true asp.net check box list
function getRadioButtonText()
{
var elementId = ‘<%=RadioButtonList1.ClientID%>’;
var elementRef = document.getElementById(elementId);
var checkBoxArray = elementRef.getElementsByTagName(‘input’);
var checkedValue = ”;
var isChecked = false;
for (var i = 0; i < checkBoxArray.length; i++) {
if (document.getElementById(elementId + “_” + i.toString()).checked == true) {
var checkBoxRef = checkBoxArray[i];
var labelArray = checkBoxRef.parentNode.getElementsByTagName(‘label’);
checkedValue = labelArray[0].innerHTML;
alert(checkedValue);
Chekced = false;
break;
}
}
}
Please post a JQuery solution if you have .
Tags: Asp.net, asp.net radiobutton list, javascript, JQuery, radiobutton list text

Java script code was not working so I’ve changed it, this is 100% working code. Sorry! for any inconvenience caused.
jQuery solution: (for this problem)
$(‘#’).find(“input[CHECKED]“).val()
Ur correct sudha i also use in this syntax in my site .
jQuery Solution:
$(’#’).find(â€input[CHECKED]“).val();
instead of #…please use #
Excellent.Thanks a Lot
like Sutha said:
$(“#”).find(“input[CHECKED]“).val()
like Sutha said:
$(‘’).find(â€input[CHECKED]“).val()
It saved my life
Thanks a lot
the code is work…
thanks for sharing this valuable code!
Hey, This solution works like a charm.
Thanks a ton.
Jyothi
Hey thanks a lot for such a valuable code. I had left hopes…. Thanks a lot.
Life Saver. Thank you.
Thank you very much man. Great post.
Hello Everyone,
This is very nice article !!!!!!! really great.
you can use javascript in same manner with simple html radiobutton, for example please check out the following links…..
http://www.mindstick.com/Blog/233/Get%20checked%20radiobutton%20using%20JavaScript
Thanks !!!!!!