how to get data from not disabled checkbox

how to get data from not disabled checkbox

idnidn Posts: 2Questions: 1Answers: 0
edited September 2022 in Free community support

hello everyone, i've been trying to select all data from checkbox in my datatable that is not disabled but i always get all data. sorry i cannot make a standard question about my problem. the code im using now is this
dataTable
.rows( function ( idx, data, node ) {
return $(node).find('input[type="checkbox"][name="chkbx"]:not(:disabled)');
} )
.data()
.toArray();
the condition now is that i have checkbox in all <td> and i made button called select all outside datatable. the reason i create select all outside datatable <th> is that i've been trying to set select all inside datatable with client side and if data is big, the select all really have a long wait to process checked, so i have idea to make button to select all data outside datatable and when i click it will get all data that is not disabled checkbox and push into variable to submit into database.
so any reference about the code to get all data from checkbox that is not disabled?
sorry bad english.
thanks

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,145Questions: 26Answers: 4,736
    Answer ✓

    You need to return a boolean value. Currently you are returning the jQuery object whether it finds the checkbox or not. Maybe something like this will work by checking the it returns one checkbox:

    return $(node).find('input[type="checkbox"][name="chkbx"]:not(:disabled)').length === 1;
    

    Kevin

  • idnidn Posts: 2Questions: 1Answers: 0

    @kthorngren thanks a lot it help sensei!

Sign In or Register to comment.