As far as I know, you can't get the selected value of a radio button
directly. You need to iterate through each item in the group, until you
find the selected item, and then get its value. An example of how to do
this is below:
<script language="javascript">
function GetVal()
{
var a = null;
var f = document.forms[0];
var e = f.elements["RadioButtonList1"];
for (var i=0; i < e.length; i++)
{
if (e[i].checked)
{
a = e[i].value;
break;
}
}
return a;
}
</script>
Hope this helps,
Mun
"mg" <mg@theworld.com> wrote in message
news:03****************************@phx.gbl...
After a selection is made in the following RadioButtonList
<asp:RadioButtonList id="RadioButtonList1" runat="server">
<asp:ListItem Value="Y"></asp:ListItem>
<asp:ListItem Value="N"></asp:ListItem>
</asp:RadioButtonList>
the following script [in a client-side CustomValidator]
returns null, not "Y" or "N"
<script language="javascript">
q = document.getElementById
("RadioButtonList1").getAttribute("SelectedValu e")
alert(q)
</script>
Can you tell me what I'm doing wrong?