//jQuery search filtering $(document).ready(function(){ //count each table BEFORE user input var rowCount_master = $('.table_data tr:visible:not(:has(th))').length; $('#row_count_master').html(rowCount_master); var rowCount_utlan = $('#table_data_utlan tr:visible:not(:has(th))').length; $('#row_count_utlan').html(rowCount_utlan); var rowCount_totaloversikt = $('#table_data_totaloversikt tr:visible:not(:has(th))').length; $('#row_count_totaloversikt').html(rowCount_totaloversikt); var rowCount_midlansatt = $('#table_data_midlansatt tr:visible:not(:has(th))').length; $('#row_count_midlansatt').html(rowCount_midlansatt); var rowCount_table = $('.table_data tr:visible:not(:has(th))').length; $('#row_count').html(rowCount_table); //frontpage only - master table search, search filter in ALL tables $("#table_search_master").on("keyup", function() { var value_master = $(this).val().toLowerCase(); $(".table_data tr:not(:has(th))").filter(function() { $(this).toggle($(this).text().toLowerCase().indexOf(value_master) > -1) }); //counts number of table rows var rowCount_master = $('.table_data tr:visible:not(:has(th))').length; $('#row_count_master').html(rowCount_master); if (rowCount_master == 0) { $('#no_result_master').css('display', 'block'); } else { $('#no_result_master').css('display', 'none'); } }); //frontpage only - only utlan table search filter $("#table_search_utlan").on("keyup", function() { var value_utlan = $(this).val().toLowerCase(); $("#table_data_utlan tr:not(:has(th))").filter(function() { $(this).toggle($(this).text().toLowerCase().indexOf(value_utlan) > -1) }); var rowCount_utlan = $('#table_data_utlan tr:visible:not(:has(th))').length; $('#row_count_utlan').html(rowCount_utlan); if (rowCount_utlan == 0) { $('#no_result_utlan').css('display', 'block'); } else { $('#no_result_utlan').css('display', 'none'); } }); //frontpage only - only totaloversikt table search filter $("#table_search_totaloversikt").on("keyup", function() { var value_totaloversikt = $(this).val().toLowerCase(); $("#table_data_totaloversikt tr:not(:has(th))").filter(function() { $(this).toggle($(this).text().toLowerCase().indexOf(value_totaloversikt) > -1) }); var rowCount_totaloversikt = $('#table_data_totaloversikt tr:visible:not(:has(th))').length; $('#row_count_totaloversikt').html(rowCount_totaloversikt); if (rowCount_totaloversikt == 0) { $('#no_result_totaloversikt').css('display', 'block'); } else { $('#no_result_totaloversikt').css('display', 'none'); } }); //frontpage only - only midlansatt table search filter $("#table_search_midlansatt").on("keyup", function() { var value_midlansatt = $(this).val().toLowerCase(); $("#table_data_midlansatt tr:not(:has(th))").filter(function() { $(this).toggle($(this).text().toLowerCase().indexOf(value_midlansatt) > -1) }); var rowCount_midlansatt = $('#table_data_midlansatt tr:visible:not(:has(th))').length; $('#row_count_midlansatt').html(rowCount_midlansatt); if (rowCount_midlansatt == 0) { $('#no_result_midlansatt').css('display', 'block'); } else { $('#no_result_midlansatt').css('display', 'none'); } }); //not frontpage - common search filter for each individual site with a table $("#table_search").on("keyup", function() { var value_table = $(this).val().toLowerCase(); $(".table_data tr:not(:has(th))").filter(function() { $(this).toggle($(this).text().toLowerCase().indexOf(value_table) > -1) }); var rowCount_table = $('.table_data tr:visible:not(:has(th))').length; $('#row_count').html(rowCount_table); if (rowCount_table == 0) { $('#no_result').css('display', 'block'); } else { $('#no_result').css('display', 'none'); } }); }); //jQuery search filtering $(document).ready(function(){ //frontpage only - master table search, search filter in ALL tables $("#table_search_master").on("keyup", function() { var value_master = $(this).val().toLowerCase(); $(".table_data tr:not(:has(th))").filter(function() { $(this).toggle($(this).text().toLowerCase().indexOf(value_master) > -1) }); //counts number of table rows var rowCount_master = $('.table_data tr:visible:not(:has(th))').length; $('#row_count_master').html(rowCount_master); if (rowCount_master == 0) { $('#no_result_master').css('display', 'block'); } else { $('#no_result_master').css('display', 'none'); } }); //frontpage only - only utlan table search filter $("#table_search_utlan").on("keyup", function() { var value_utlan = $(this).val().toLowerCase(); $("#table_data_utlan tr:not(:has(th))").filter(function() { $(this).toggle($(this).text().toLowerCase().indexOf(value_utlan) > -1) }); var rowCount_utlan = $('#table_data_utlan tr:visible:not(:has(th))').length; $('#row_count_utlan').html(rowCount_utlan); if (rowCount_utlan == 0) { $('#no_result_utlan').css('display', 'block'); } else { $('#no_result_utlan').css('display', 'none'); } }); //frontpage only - only totaloversikt table search filter $("#table_search_totaloversikt").on("keyup", function() { var value_totaloversikt = $(this).val().toLowerCase(); $("#table_data_totaloversikt tr:not(:has(th))").filter(function() { $(this).toggle($(this).text().toLowerCase().indexOf(value_totaloversikt) > -1) }); var rowCount_totaloversikt = $('#table_data_totaloversikt tr:visible:not(:has(th))').length; $('#row_count_totaloversikt').html(rowCount_totaloversikt); if (rowCount_totaloversikt == 0) { $('#no_result_totaloversikt').css('display', 'block'); } else { $('#no_result_totaloversikt').css('display', 'none'); } }); //frontpage only - only midlansatt table search filter $("#table_search_midlansatt").on("keyup", function() { var value_midlansatt = $(this).val().toLowerCase(); $("#table_data_midlansatt tr:not(:has(th))").filter(function() { $(this).toggle($(this).text().toLowerCase().indexOf(value_midlansatt) > -1) }); var rowCount_midlansatt = $('#table_data_midlansatt tr:visible:not(:has(th))').length; $('#row_count_midlansatt').html(rowCount_midlansatt); if (rowCount_midlansatt == 0) { $('#no_result_midlansatt').css('display', 'block'); } else { $('#no_result_midlansatt').css('display', 'none'); } }); //not frontpage - common search filter for each individual site with a table $("#table_search").on("keyup", function() { var value_table = $(this).val().toLowerCase(); $(".table_data tr:not(:has(th))").filter(function() { $(this).toggle($(this).text().toLowerCase().indexOf(value_table) > -1) }); var rowCount_table = $('.table_data tr:visible:not(:has(th))').length; $('#row_count').html(rowCount_table); if (rowCount_table == 0) { $('#no_result').css('display', 'block'); } else { $('#no_result').css('display', 'none'); } }); }); //jQuery search filtering $(document).ready(function(){ //count each table BEFORE user input var rowCount_master = $('.table_data tr:visible:not(:has(th))').length; $('#row_count_master').html(rowCount_master); var rowCount_utlan = $('#table_data_utlan tr:visible:not(:has(th))').length; $('#row_count_utlan').html(rowCount_utlan); var rowCount_totaloversikt = $('#table_data_totaloversikt tr:visible:not(:has(th))').length; $('#row_count_totaloversikt').html(rowCount_totaloversikt); var rowCount_midlansatt = $('#table_data_midlansatt tr:visible:not(:has(th))').length; $('#row_count_midlansatt').html(rowCount_midlansatt); var rowCount_table = $('.table_data tr:visible:not(:has(th))').length; $('#row_count').html(rowCount_table); //frontpage only - master table search, search filter in ALL tables $("#table_search_master").on("keyup", function() { var value_master = $(this).val().toLowerCase(); $(".table_data tr:not(:has(th))").filter(function() { $(this).toggle($(this).text().toLowerCase().indexOf(value_master) > -1) }); //counts number of table rows var rowCount_master = $('.table_data tr:visible:not(:has(th))').length; $('#row_count_master').html(rowCount_master); if (rowCount_master == 0) { $('#no_result_master').css('display', 'block'); } else { $('#no_result_master').css('display', 'none'); } }); //frontpage only - only utlan table search filter $("#table_search_utlan").on("keyup", function() { var value_utlan = $(this).val().toLowerCase(); $("#table_data_utlan tr:not(:has(th))").filter(function() { $(this).toggle($(this).text().toLowerCase().indexOf(value_utlan) > -1) }); var rowCount_utlan = $('#table_data_utlan tr:visible:not(:has(th))').length; $('#row_count_utlan').html(rowCount_utlan); if (rowCount_utlan == 0) { $('#no_result_utlan').css('display', 'block'); } else { $('#no_result_utlan').css('display', 'none'); } }); //frontpage only - only totaloversikt table search filter $("#table_search_totaloversikt").on("keyup", function() { var value_totaloversikt = $(this).val().toLowerCase(); $("#table_data_totaloversikt tr:not(:has(th))").filter(function() { $(this).toggle($(this).text().toLowerCase().indexOf(value_totaloversikt) > -1) }); var rowCount_totaloversikt = $('#table_data_totaloversikt tr:visible:not(:has(th))').length; $('#row_count_totaloversikt').html(rowCount_totaloversikt); if (rowCount_totaloversikt == 0) { $('#no_result_totaloversikt').css('display', 'block'); } else { $('#no_result_totaloversikt').css('display', 'none'); } }); //frontpage only - only midlansatt table search filter $("#table_search_midlansatt").on("keyup", function() { var value_midlansatt = $(this).val().toLowerCase(); $("#table_data_midlansatt tr:not(:has(th))").filter(function() { $(this).toggle($(this).text().toLowerCase().indexOf(value_midlansatt) > -1) }); var rowCount_midlansatt = $('#table_data_midlansatt tr:visible:not(:has(th))').length; $('#row_count_midlansatt').html(rowCount_midlansatt); if (rowCount_midlansatt == 0) { $('#no_result_midlansatt').css('display', 'block'); } else { $('#no_result_midlansatt').css('display', 'none'); } }); //not frontpage - common search filter for each individual site with a table $("#table_search").on("keyup", function() { var value_table = $(this).val().toLowerCase(); $(".table_data tr:not(:has(th))").filter(function() { $(this).toggle($(this).text().toLowerCase().indexOf(value_table) > -1) }); var rowCount_table = $('.table_data tr:visible:not(:has(th))').length; $('#row_count').html(rowCount_table); if (rowCount_table == 0) { $('#no_result').css('display', 'block'); } else { $('#no_result').css('display', 'none'); } }); }); I wrote a few identical functions for each table to filter them withbased on the use ofuser input fieldstyped in the input fields using jQuery. After filtering it counts the rows that are left visible.
My code is a bit flawed because I have one function for each selector or class, which is messy and can definitely be improved but after countless hours of investigating I'm exhausted.
I wrote a few identical functions for each table to filter them with the use of input fields in jQuery. My code is a bit flawed because I have one function for each selector or class, which is messy and can definitely be improved but after countless hours of investigating I'm exhausted.
I wrote a few identical functions for each table to filter them based on the user input typed in the input fields using jQuery. After filtering it counts the rows that are left visible.
My code is a bit flawed because I have one function for each selector or class, which is messy and can definitely be improved but after countless hours of investigating I'm exhausted.