Reading hidden values

Reading hidden values

Jay77Jay77 Posts: 4Questions: 3Answers: 0

Hi,

I have populated my table with a student names and a checkbox (active/inactive).

When the admin clicks the Update button, I need to read through all students and update the database.

If the admin has searched by surname (E.g Bloggs), the non-matching students are hidden from view.

When I try to read through the checkboxes, I'm only able to pickup those that are showing at that time ('Joe bloggs').

I'm using the following code:

$('[id^="student-id-"]').each(function () {
alert($(this).val());
});

How can I read through all the rows/checkboxes?

Thanks

Answers

  • kthorngrenkthorngren Posts: 21,301Questions: 26Answers: 4,946

    Are you using Datatables?

    Its hard to tell with the above code and description. If you are using Datatables then please post the relevant JS code showing the Datatables and how you are searching and handling the checkboxes.

    Kevin

  • Jay77Jay77 Posts: 4Questions: 3Answers: 0

    Hi Kevin,

    Thanks for the reply.

    I'm creating the datatable using:

    $('.tblStudents').dataTable({
        "columnDefs": [{ "targets": [0], "visible": true, orderable: !1, "searchable": true }],
        "order": [[2, "asc"], [1, "asc"]],
        "paging": true,
        "ordering": true,
        "info": false,
        lengthMenu: [[10, 25, -1], [10, 25, "All"]],
        pageLength: 10
    });
    

    The table has 3 columns, the checkboxes are in columns 2 and 3. The admin is the one who searches, using the search box (the default search box included with the datatable script).

    The row is as follows:

    <tr>
    <td>Joe Bloggs</td>
    <td>
    <label class="mt-checkbox mt-checkbox-single mt-checkbox-outline">
    <input type="checkbox" class="checkboxes" id="student-id-09" value="309" checked /><span></span></label>
    </td>
    <td>
    <label class="mt-checkbox mt-checkbox-single mt-checkbox-outline">
    <input type="checkbox" class="checkboxes" id="example-id-309" value="309" checked /><span></span></label>
    </td>
    </tr>

This discussion has been closed.