Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery checking which radiobutton is checked

Tags:

jquery

asp.net

I got 2 radiobutton and 1 radcombobox

<asp:RadioButton ID="cbxYes" Width="60" Height="30" runat="server" GroupName="proffesional" OnCheckedChanged="cbxYes_CheckedChanged" />
<asp:RadioButton ID="cbxNo" runat="server" Width="60" Height="30" GroupName="proffesional" Checked="true" OnCheckedChanged="cbxNo_CheckedChanged" />
<telerik:RadComboBox ID="dblSelect" EnableEmbeddedSkins="false" BackColor="Black" ForeColor="#d8d8d8" runat="server" Width="200" Height="30" ></telerik:RadComboBox>

. don't use clientidmode=static and i want to show or hide radcombobox according what radiobutton is checked.

I have written this code:

<script type="text/javascript">
$(document).load(function () {
    var dropdown = $('#<%= dblSelect.ClientID%>');
    var radio1 = $('#<%= cbxYes.ClientID%>');
    var radio2 = $('#<%= cbxNo.ClientID%>');
    if ((radio1.is(':checked').val()) == 'true') {
        dropdown.is(':visible').val() = 'true';
    };
    if((radio2.is(':checked').val() == 'false'){
        dropdown.is(':visible').val() = 'false';
    };
});
</script>

What am I doing wrong?

Thanks in advance :)

like image 567
Harry89pl Avatar asked Oct 26 '11 14:10

Harry89pl


1 Answers

jQuery's is returns a boolean.

if (radio1.is(':checked')) {
    dropdown.show();
};
if(radio2.is(':checked')){
    dropdown.hide();
};
like image 124
Dennis Avatar answered Oct 06 '22 13:10

Dennis