我在 .aspx 页面上有以下单选按钮列表:
<asp:RadioButtonList ID="rbList" runat="server">
<asp:ListItem Text="I accept" Value="accept" />
<asp:ListItem Text="I decline" Value="decline" Selected="True" />
</asp:asp:RadioButtonList>
默认选择第二个 radio 。我有没有办法确定用户是否没有选择第一个选项,即,当他们执行操作时是否仍然选择了“拒绝”?
例如:
function checkRbList() {
var rbl = document.getElementById(<%= rbList.ClientID %>);
//if "decline" is still selected, alert('You chose to decline')...
}
最佳答案
下面应该做的工作:
var rbl = document.getElementById("<%= rbList.ClientID %>");
var value = rbl.value;
if(value === 'decline')
alert()
关于javascript - 使用 JavaScript 获取 SelectedValue ASP.NET RadiobuttonList,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47543804/