I have a radibutton list.
<asp:RadioButtonList ID="RadioButtonList1" runat="server"
RepeatDirection="Horizontal" RepeatLayout="flow" >
<asp:ListItem Selected="True" Text ="Yes" Value="0"></asp:ListItem>
<asp:ListItem Text ="No" Value="1"></asp:ListItem>
</asp:RadioButtonList>
And to get the value from radio list I have a function :
function getvalueofradiolist() {
var radiolist = document.getElementById('<%= RadioButtonList1.ClientID %>');
var rblName = radiolist.name;
var radio = document.getElementsByName(rblName);
for (var x = 0; x < radio.length; x++) {
if (radio[x].checked) {
alert("Selected item Value " + radio[x].value);
}
}
}
But it returns undefined.
Did I write something wrong?
I am calling this function on button click.
Suggest me If I can do this with the help of code behind in spite of Javascript.
1 Answer