How can I determine the SelectedValue of a RadioButtonList in JavaScript?

前端 未结 13 2135
一生所求
一生所求 2020-12-16 15:20

I have an ASP.NET web page with a databound RadioButtonList. I do not know how many radio buttons will be rendered at design time. I need to determine the SelectedValue on

13条回答
  •  失恋的感觉
    2020-12-16 16:02

    For a 'RadioButtonList with only 2 values 'yes' and 'no', I have done this:

    var chkval=document.getElemenById("rdnPosition_0")
    

    Here rdnposition_0 refers to the id of the yes ListItem. I got it by viewing the source code of the form.

    Then I did chkval.checked to know if the value 'Yes' is checked.

提交回复
热议问题