Search code examples
jqueryradiobuttonlist

Unchecking radiobutton list using jquery


Ok, last question for today I promise!

I have the following line of code that features a radio button list (radTopx)

ddlBuyer.Attributes.Add("onclick", "$('#tbxProdAC').val(''); $('#txtbxHowMany').val(''); $('#GridView1').remove(); $('#radTopx').attr('checked',false); ");

What I am trying to achieve is that when ddlBuyer is clicked, radTopx has all it's radio buttons unchecked.

I am obviously doing this incorrectly at present, please can someone pointout where I have gone wrong? Does this work differently in a radio button list to a standard radio button?

Where #radTopx represents the following radio button list :

RadioButtonList ID="radTopx"

    ListItem>UUF1<ListItem>
    ListItem>UUF2<ListItem>
    ListItem>UUF3<ListItem>

RadioButtonList


Solution

  • $('#ddlBuyer').click(function() {
        $('div#radios input').attr('checked',false);
    });
    

    where div#radios encloses all your radio inputs. I'm assuming ddlBuyer is the id of something that gets clicked.

    We can't give an answer in regard to #radTopx since we don't know what it is.