Gives solution for any Error occurs in any Programming Language, .Net Core 3.1, 3.0, C#,Asp.Net,Sqlserver,MVC,Java,Php,Html,Css,Jquery,errors and solutions,Latest News,Technology

Thursday, 28 April 2016

How to use Select All checkboxes and getting values into array using JavaScript and jQuery

No comments :
Here I will explain about Select and UnSelect all checkboxes using single Select All checkbox. To use this code you need jQuery plugin version 1.6 and above. If you want to get selected checkboxes values use the below code.

HTML:
<input type="checkbox" id="chkAll" />
<input type='checkbox' name='chkSelect' value=" + slno + " class='chkSelect'>

JavaScript:
$("#chkAll").change(function () {
                $(".chkSelect").prop('checked', $(this).prop("checked"));              
 });

var arrayCatIds = [];//Declare array.
            $('input:checkbox[name=chkSelect]:checked').each(function () {
                arrayCatIds.push($(this).val());//Here pushing all selected checkboxes into array
            });

No comments :

Post a Comment