0

10 レコードのみを表示し、ページネーションを使用して次の 10 レコードを表示する動的テーブルがあります。検索機能が欲しい。このガイドhttp://www.vonloesch.de/node/23に従っていますが、最初の 10 レコードしか検索できません。

どんな助けでも大歓迎です。ありがとう

4

1 に答える 1

0

この関数は、指定したリンクのように 1 つのセルだけではなく、各行の内容に基づいてテーブル全体の行をフィルター処理します。

// text => the text to search for
// _id => id of table to filter
// noOfHeaderRows => number of header rows :)
function filterTable( text, _id, noOfHeaderRows ) {

    var table = document.getElementById( _id ), contents, row;

    for (var r = noOfHeaderRows; r < table.rows.length; r++){

        row = table.rows[r];
        contents = row.textContent || row.innerText; 
        contents = contents.toUpperCase();
        text = text.toUpperCase();

        if( contents.indexOf( text ) > -1 ) {
            row.style.display = "";
        } else {
            row.style.display = "none";
        }

    }
}

ここでフィドル

于 2012-11-16T14:09:55.213 に答える