gpt4 book ai didi

javascript - 使用 JavaScript 获取 SelectedValue ASP.NET RadiobuttonList

转载 作者:太空宇宙 更新时间:2023-11-03 20:59:06 25 4
gpt4 key购买 nike

我在 .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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com