Event to calculate searched items in the table

Asked

Viewed 45 times

1

I need to calculate table items and show in a given field of my page.

There is a search field with some filters, as it is researched appear the patients in the table, with the event I wanted to hear the patients as they are researched and show the result (number of patients who were found) in another field.

The id="countPatients" is a < span > where the number of patients surveyed should appear.

.patient-table-plugin is my table

My event at . js is like this:

Pacientes.prototype = {
     $('.pacientes-table-plugin').on('change', function(){
          self.count_pac();
     });
}

And my function so:

count_pac : function(){
     const t = $('.pacientes-table-plugin tr').length;
     $('#countPacientes').text(t);
}

But my event is not working

  • You want to count the number of rows, columns or cells?

  • Possible duplicate of Calculate items from a table

  • 1

    Better continue editing your original question instead of opening two new questions with the same content.

  • The amount of lines

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.