mardi 3 janvier 2017

How to get event of select all checkbox from jquery file?

Hi I am developing one asp.net application. I have listbox with multiselect option. I have select all checkbox on top pf it. When i select few options from listbox I am able to get selected values. When i uncheck the selec all i want to do some processing. So I want to get event for that,

<script type="text/javascript">
      $(function () {
          $('[id*=ddlvendors]').multiselect({
             includeSelectAllOption: true
          });

      });
</script>

This is my html code.

<asp:ListBox ID = "ddlvendors" runat="server" SelectionMode="Multiple" class="limitedNumbSelect2" >
</asp:ListBox>

Whenever i check options i am doing below.

 $(function () {

        $('.limitedNumbSelect2').change(function (e) {
            var selected = [];
            var tempVal = [];
            $(".limitedNumbSelect2 option").each(function () {
                var val = $(this).val();
                var tempVal = $(".limitedNumbSelect2").val();
                if (tempVal.indexOf(val) >= 0 && selected.indexOf(val) < 0) {
                    selected.push(val);
                } else if (tempVal.indexOf(val) < 0 && selected.indexOf(val) >= 0) {
                    selected.splice(selected.indexOf(val), 1);
                }
            })
});

When i uncheck all above code will not work. I am binding values from database in server side. Below is mu javascript file of multiselect. http://ift.tt/1EzpXJJ

Is there any way i can modify the above file and get event for select all when i unchecked it? any help would be appreciated.




Aucun commentaire:

Enregistrer un commentaire