sGermosen
sGermosen

Reputation: 374

Trying to set the value of an asp radiobuttonlist with jQuery

I'm trying to change the value of a radiobuttonlist. I have tried too many ways, but I can't get the solution.

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

i have tried this, than uncheck all items

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

i tried this,

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

this,

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

and this,

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

This is the structure of my element:

                        <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>

Upvotes: 1

Views: 874

Answers (1)

sGermosen
sGermosen

Reputation: 374

This is working for me, i dont know if theres another way to do it, but, for now this solve my problem

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

Upvotes: 1

Related Questions