How do I get the SelectedValue from a RadioButtonList using javascript

Discussion in 'ASP .Net Web Controls' started by pierre@globalkinetic.net, Mar 29, 2005.

  1. Guest

    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
     
    , Mar 29, 2005
    #1
    1. Advertising

  2. nandha Guest

    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>
    >
    >
    >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
    >
    >.
    >
     
    nandha, Mar 29, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. thinkmast

    RadioButtonList SelectedValue

    thinkmast, May 7, 2006, in forum: .NET
    Replies:
    0
    Views:
    3,531
    thinkmast
    May 7, 2006
  2. Jeff
    Replies:
    2
    Views:
    2,344
  3. Arnold

    how to get selectedvalue of radiobuttonlist in Javascript?

    Arnold, Nov 12, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    4
    Views:
    2,285
    Arnold
    Nov 12, 2006
  4. Replies:
    0
    Views:
    168
  5. Arnold
    Replies:
    6
    Views:
    398
    MikeS
    Nov 12, 2006
Loading...

Share This Page