【问题标题】:Trying to set the value of an asp radiobuttonlist with jQuery尝试使用 jQuery 设置 asp 单选按钮列表的值
【发布时间】:2017-04-21 01:47:08
【问题描述】:

我正在尝试更改单选按钮列表的值。我尝试了太多方法,但我无法得到解决方案。

//this works perfectly to get the current value, and is the way that I saved on database, 
$('[id$=rdoPropietario] input:checked').val()

我已经尝试过了,而不是取消选中所有项目

$('[id$=rdoPropietario] input:checked').val(["1"]);

我试过了,

$('[id$=rdoPropietario] input:checked').val(1);

这个,

$('[id$=rdoPropietario  input[type=radio][value='1']').prop("checked", true); 

还有这个,

$("[name$='rdoPropietario']").find("input[value='1']").prop("checked", true); 

这是我的元素的结构:

                        <div class="col-md-3 col-sm-6  col-xs-6">
                            <asp:RadioButtonList ID="rdoPropietario" runat="server" RepeatDirection="Horizontal" ViewStateMode="Enabled">
                                <asp:ListItem Selected="True" Value="0">N/A &nbsp;</asp:ListItem>
                                <asp:ListItem Value="1">Si &nbsp;</asp:ListItem>
                                <asp:ListItem Value="2">No &nbsp;</asp:ListItem>
                            </asp:RadioButtonList>
                        </div>

【问题讨论】:

    标签: javascript jquery asp.net webforms


    【解决方案1】:

    这对我有用,我不知道是否有其他方法可以做到这一点,但是,现在这解决了我的问题

    $("[id$=rdoComunitario]").find("input[value='" + r.COMUNITARIO + "']").prop("checked", true);
    

    【讨论】:

      猜你喜欢
      • 2013-05-18
      • 2013-07-24
      • 2023-03-08
      • 2014-08-26
      • 1970-01-01
      • 1970-01-01
      • 2013-10-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多