Skip to content Skip to sidebar Skip to footer

Disable/enable Outside Asp Button Control On Datalist Checkbox Checked Javascript?

I have a datalist inside that I am using a checkbox, I have 1 asp button and 2 image buttton which is outside of datalist something like this )) { $('#Button1, #ibtnok').attr('disabled','disabled'); } else $('#Button1, #ibtnok').removeAttr('disabled'); })

If there are multiple checkboxes appearing, then you can give those checkboxes a common class, and on every change event, you need to loop through all those elements , or take a count of unchecked/checked checkboxes, and do enable/disable your button.

Looping through each of those checkboxes can be done with $('.your_common_chkbox_class').each(function_to_be_performed);

UPDATE

eg:

$('.your_common_chkbox_class').click(function(){
    if($('.your_common_chkbox_class:checked').length > 0)
        $('#Button1, #ibtnok').attr('disabled','disabled');
    else
        $('#Button1, #ibtnok').removeAttr('disabled');
})

Solution 2:

Thank you @ linuxeasy I have taken you code and modified (checkbox id) and now its working

<scripttype="text/javascript"language="javascript">
 $(function () {
    $('.CSSCheck').click(function () {
        if ($("[id$='Chkbox']:checked").length > 0) {
            $("#<%=Button1.ClientID %>").removeAttr('disabled');
        }
        else {
            $("#<%=Button1.ClientID %>").attr('disabled', 'disabled');

        }
    });
});
</script>

Post a Comment for "Disable/enable Outside Asp Button Control On Datalist Checkbox Checked Javascript?"