Live Search Filter with Checkbox PHP

2019-08-28 13:40发布

问题:

I have issue about the live search with check box. My problem is when i search one the name list the check box is automatically check. only the showed data check.

example i search world "vin" all have word vin must be checked.

this is my [sample][1]

  [1]: http://jsfiddle.net/v921/TxYqv/3/

回答1:

UPDATED answer:

Here is how your js should look like:

function filter(element) {
    var $trs = $('.AvailableGroupLab tr').hide();
    var regexp = new RegExp($(element).val(), 'i');    
    var $numberOfShownRows = 0;
    var $rows = $trs.filter(function () {   
        if($(element).val() != "")
        {
            $(this).children(':nth-child(1)').html("<input type='checkbox' checked />"); 
        }
        else
        {
            $(this).children(':nth-child(1)').html("<input type='checkbox' />");
        }  
        return regexp.test($(this).children(':nth-child(2)').text());
    });  
    $rows.show(); 
    if($rows.length == 0)
    {
        $('#message').show();
    }
    else
    {
        $('#message').hide();
    }
}

$('input:text').on('keyup change', function () { 
    filter(this); 
})

And put this div whereever you want to put your text:

<div id="message" style="display:none"> No record! </div>


标签: codeigniter