c# - ASP.Net 单选按钮列表 : using jQuery to get the ListItem selected

标签 c# jquery asp.net selecteditem radiobuttonlist

有 2 个 RadioButtonLists:

Are you a minor?:  oYes  oNo
Do you wish a joint account?:  oYes  oNo

如果第一个问题的答案是肯定的,我想检测对第一个问题的回答并使用 jQuery 函数将第二个问题的答案设置为是。提前致谢。

<asp:Label ID="lblMinfor" CssClass="boldIt" runat="server" Text="Is this account for a minor" Style="float: left; width: 200px;"></asp:Label><br />
<asp:RadioButtonList ID="rdlMinor" runat="server" RepeatDirection="Horizontal" Width="130px" Style="float: left;" BorderStyle="None" RepeatLayout="Flow" ()>
    <asp:ListItem>Yes</asp:ListItem>
    <asp:ListItem Selected="True">No</asp:ListItem>
</asp:RadioButtonList>
<asp:Label ID="lblJoint" CssClass="boldIt" runat="server" Text="Is this for a joint account?" Style="float: left; width: 200px;"></asp:Label><br />
<asp:RadioButtonList ID="rdlJoint" runat="server" RepeatDirection="Horizontal" Width="130px" Style="float: left;" BorderStyle="None" RepeatLayout="Flow">
    <asp:ListItem>Yes</asp:ListItem>
    <asp:ListItem Selected="True">No</asp:ListItem>
</asp:RadioButtonList>

最佳答案

$('#<%=rdlMinor.ClientID %>').change(function() {
    if($('#<%=rdlMinor.ClientID %> input:checked').val() == 'Yes') 
    {
        $('#<%=rdlJoint.ClientID %>').find("input[value='Yes']").attr("checked", "checked");
    }
});

关于c# - ASP.Net 单选按钮列表 : using jQuery to get the ListItem selected,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9403451/

相关文章:

c# - HRESULT 异常 : 0x800A03EC Error

c# - XNA 中的多点触控事件

javascript - 使用 showLoaderOnConfirm 时禁用 Sweet Alert 中的输入文本框

javascript - Canvasjs 图表中的渲染数据

c# - Asp.Net MVC4 显示复选框列表

c# - 在代码后面设置图像按钮的不透明度

c# - 检查 Linq 结果中的 DateTime 是否为 Null 的语法

javascript - Div 行为不稳定。关于崩溃和崩溃

jquery - 嵌入标签 <b> Jquery

c# - UWP 应用程序在不处于 Debug模式时崩溃