1
I have a table #table and I would like every time I make a filter by select it to add the amount that is in column 6 eq(5). With the code below it is running, however it displays the previous value I select. For example, it is displaying 3 lines with 5, 5 and 5 in each of them. When I change the option of select for any other option, then it will show me the sum, 25 on the console.
$('select').on('change', function() {
var qtd = 0
$("#tabela tbody tr:not(.filtered)").each(function(){
qtd += parseInt($(this).find('td').eq(5).html())
});
console.log(qtd);
});
What event could I use for him to calculate when I change the selection of <select>
. I had thought of the obvious, the change.
I am beginner eh jQuery, so if the code can be written in a better way, feel free to suggest.
Thank you.
The value of select doesn’t really matter to me. I use it only for filter, if I select Test option, it filters to 3 rows in the table, for example. I then count the filtered lines, by the class .filtered. And so I add up the face line to know the total I have.
– netovgs
If when changing the select is made the stroke and at the same time called the "onchange", will give problem because the two things will not be processed in sync.
– Sam
It is jQuery himself who makes a script that uses the tablesorter class. Look at this image https://uploaddeimagens.com.br/imagens/img-jpg-188. I want to add 50 + 1 when I change the filter of any select (black arrow). It adds up, but it will show the 51 only after I change the filter again.
– netovgs
And how could I make it work, is it possible?
– netovgs
The plugin is this http://tablesorter.com/docs/?
– Sam
Still counting after I change my options. =/
– netovgs
This is how the ths are: <th data-placeholder='Filter' class='filter-select filter-Exact'><b>Nº License</b></th> and the table: <table id='table' class='tablesorter'>
– netovgs