react pagination posting field values from page one only

70 Views Asked by At

I have added a react pagination in my react application. in there I have some data along with checkboxes ( which are by default selected ). When I click on final submit button without making any change ( without selecting or deselecting checkboxes as all are by default selected ), it is submitting values of checkboxes from page 1 only and not from other pages.

For Ex.

Page 1 contains

checkbox1 checkbox2 checkbox3

Page 2 contains

checkbox 4 checkbox 5

On final submit button on the form I want to submit values of all the checkboxes which are selected.

I tried below code

let selectedItems = []; 
const allCheckboxes = document.getElementsByName('items'); 
for( let i = 0; i < allCheckboxes.length; i++) {
    if(allCheckboxes[i].checked) {
        selectedItems.push( allCheckboxes[i].value );
    } }

on printing selectedItems..I am getting values which are present on page 1 of pagination

Any help is appreciated. Thanks in advance

0

There are 0 best solutions below