lundi 24 juillet 2017

submit button doesnot hides when 'check-all' checkbox is unchecked

I am trying to make a page where submit button show/hides when a checkbox is checked. The same I want to do with the 'check-all' and currently when check-all is checked, the submit button appears but when the 'check-all' gets unchecked the submit button does not hides. Although the listed checkboxes perforn absolutely fine but only the unchecking of 'check-all' does not makes the submit button hide.

here is my code, please let me know where I am going wrong and if there is any solution for it.

<input type="checkbox" id="select_all" name="all_check[]" class="checkbox" value= "<?php echo $row['id']; ?>"/> </th> //this is my 'check-all'

<input type="checkbox" name="check[]" <?php echo $disabled ;?> value= "<?php echo $row['id']; ?>"class="checkbox" id="select_all" > //this is my listed checkboxes under the 'check-all'

and jquery,

$(function(){
    $('[type=checkbox]').click(function ()
    {
        var checkedChbx = $('[type=checkbox]:checked');
        if (checkedChbx.length > 0)
        {
            $('#one').show();
        }
        else
        {
            $('#one').hide();
        }
    });
});


  $(document).ready(function() {

        var $submit = $("#one").hide(),
            $cbs = $('input[name="all_check[]"]').click(function() {
                $submit.toggle( $cbs.is(":checked") );
            });

    });




Aucun commentaire:

Enregistrer un commentaire