Home All Groups Group Topic Archive Search About

How do I get the SelectedValue from a RadioButtonList using javascript

Author
29 Mar 2005 1:09 PM
pierre
Can anyone tell me how to get the SelectedValue from a ASP.net
RadioButtonList, using javavscript.

Here is my code:

<ASP:RADIOBUTTONLIST id="optOption" runat="server"
ONCLICK="javascript:alert(docu­ment.all.optOption.selectedIte­m);"></ASP:RADIOBUTTONLIST>


This is not working. I am getting an error saying that
'document.all.optOption.select­edItem is null or not an object'.

Thanks in advance,
Pierre

Author
29 Mar 2005 2:34 PM
nandha
Hi,

Please remove inline javascript code.
<ASP:RADIOBUTTONLIST id="optOption"
runat="server"></ASP:RADIOBUTTONLIST>

Add the following code in the code behind file.

Private Sub Page_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

optOption.Attributes.Add("OnClick", "alert(" &
optOption.ClientID.ToString & ".value)")
End Sub

Regards,
nandha.


>-----Original Message-----
>Can anyone tell me how to get the SelectedValue from a
ASP.net
>RadioButtonList, using javavscript.
>
>Here is my code:
>
><ASP:RADIOBUTTONLIST id="optOption" runat="server"
>ONCLICK="javascript:alert(docu­
ment.all.optOption.selectedIte­m);"></ASP:RADIOBUTTONLIST>
Show quoteHide quote
>
>
>This is not working. I am getting an error saying that
>'document.all.optOption.select­edItem is null or not an
object'.
>
>Thanks in advance,
>Pierre
>
>.
>