Skip to content Skip to sidebar Skip to footer

Merge Search Results From Multiple Field Inputs

I asked a question about live searching a table but I have multiple fields like text and select dropdown fields. I wrote a js code based on the answer I got from my previous questi

Solution 1:

Consider your deviceName field is the first column then you can write like this to search in this column only

$(document).ready(function(){
  $("#deviceName").keyup(function(){
    var deviceNameFilter = $(this).val();
    $("#device-list_table td:first-child ").each(function(){
       if ($(this).text().search(newRegExp(deviceNameFilter, "i")) < 0) {
         $(this).parent().hide();
       }else {
         $(this).parent().show();
       }
  });
});

And your broadcastProg is in second column then you can give td:nth-child(2) instead of td:first-child

For merging you need to implement some logic..for eg: You are showing element in the else part right? there you can give an if condition like this

if( $("#broadcastProg option:selected").text()== ""){
        $(this).parent().show();
  }

Post a Comment for "Merge Search Results From Multiple Field Inputs"