Here is the source code for your product solution

//execute search function
function filter(){    
    //get input value
    var q=document.getElementById(‘txtsearch’).value;
    
    var regex = new RegExp(q, ‘i’);// ignore uppercase
    //get #datasource’s table tr element from secont row, pecifies a function to run for each tr element.
    $(‘#datasource tr’).slice(1).each(function(i, tr){
        var tr = $(tr);
        var str = tr.text();//get  tr element text value
        //if statement to check whether the regex value equal than str value            
        if(regex.test(str)){
            tr.show();//show match tr elements
        }else{
            
            tr.hide();//hide not match  tr elements    
            
        }        
    });
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s