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

前端 未结 13 2137
一生所求
一生所求 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 15:47

    The HTML equivalent to ASP.NET RadioButtonList, is a set of with the same name attribute(based on ID property of the RadioButtonList).

    You can access this group of radio buttons using getElementsByName. This is a collection of radio buttons, accessed through their index.

    alert( document.getElementsByName('RadioButtonList1') [0].checked );
    

提交回复
热议问题