javascript - Counting elements once after page load -


i passing 1 value search.php filtering.php. using $_get accomplish that. in filtering.php page have table auto filters based on word typed in input text box. passing value in url like: http://holaweblearning.co.nf/php_learning/filtering.php?key=dragoo. value url taken , placed in input text box , results displayed. able run function counts filtered results based on word. issue: result count off, shows correct value after clicking on result adds 1? demo

$(document).ready(function($) {  //trigger key on search box show results word $('input#filter').trigger('keyup');  //counts results function result_count(){       var text =  $('.footable tbody tr:not(.footable-filtered)').length;       $('h5#result_count').text('number of results: '+text);     } result_count();  //run on page load window.setinterval(result_count, 100);  }); 

when click on result, new row added following , since type of row not being excluded count, count go one.

<tr class="footable-row-detail"><td class="footable-row-detail-cell" colspan="3"><div class="footable-row-detail-inner"><div class="footable-row-detail-row"><div class="footable-row-detail-name">job title:</div><div class="footable-row-detail-value">traffic court referee</div></div><div class="footable-row-detail-row"><div class="footable-row-detail-name">dob:</div><div class="footable-row-detail-value">22 jun 1972</div></div></div></td></tr> 

probably function should be:

function result_count(){       var text =  $('.footable tbody tr:not(.footable-filtered,.footable-row-detail)').length;       $('h5#result_count').text('number of results: '+text); } 

so not count row.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -