techques
asked on
How to get radiobuttonlist selected value in aspx?
Hi
I need to get the selected value of a radio button list in aspx by javascript.
But it is undefined. I tried ctl01_op too as I saw the id changed to it in html.
I need to get the selected value of a radio button list in aspx by javascript.
But it is undefined. I tried ctl01_op too as I saw the id changed to it in html.
function cald() {
var radioList = document.getElementsByName("op");
for( var i=0; i < radioList.length; ++i)
{
if( radioList[i].checked)
{
alert("Checked item: " + radioList[i].value)
}
}
}
<asp:RadioButtonList Runat="server" ID="op" name="op" RepeatDirection="Horizontal" TextAlign="Left" onchange='cald()'>
<asp:ListItem Value="*" Selected="true">*</asp:ListItem>
<asp:ListItem Value="/">/</asp:ListItem>
</asp:RadioButtonList>
ASKER
the js error said it does not support this property or method.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
excellent!
var radioList = document.getElementsById(<