Jonathan
Jonathan

Reputation: 1027

How to get all selected checkbox from multiple pagination page in asp.net mvc?

Could someone please help me to understand how can i get all the checkbox were checked throughout all the pagination page?

using below seem only show the current page checkbox, not all pages.

Not sure if anything miss out, thanks for enlightenment!

$('input[name=myCheckbox]:checked');

Thanks in advance for your help!

Upvotes: 1

Views: 2550

Answers (1)

Vivekh
Vivekh

Reputation: 4259

This might be what you are looking for

           <input type="checkbox" onchange="selectCheckbox(this)" />

 var selectedUnits = [];
                function selectCheckbox(data) {
                    if (selectedUnits.length < 1) {
                        selectedUnits.push(data.value);
                    }
                    else {
                        if (data.checked == true) {
                            if ($.inArray(data.value, selectedUnits) < 0) {
                                selectedUnits.push(data.value);
                            }
                            else {
                                selectedUnits.pop(data.value);
                            }
                        }
                        else {
                            selectedUnits.pop(data.value);
                        }

                    }
                }

Upvotes: 1

Related Questions