1
私はJSで初心者です。私はデータベースから約100のレコードのテーブルを持っていますが、ページ上で10にページ番号が付けられています。クエリで検索すると、テーブル全体を検索するのではなく、現在のページを検索します。ページ単位での検索 - JS
現在のページだけでなく、テーブル全体を検索するクエリを取得するにはどうすればよいですか?
<script>
function myFunction() {
// Declare variables
var input, filter, table, tr, td, i;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
table = document.getElementById("table");
tr = table.getElementsByTagName("tr");
// Loop through all table rows, and hide those who don't match the search query
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[1];
if (td) {
if (td.innerHTML.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
</script>
データがページに完全に読み込まれていないため、試行していることを行うことはできません。データを検索して結果を返すには、サーバーに要求をポストする必要があります。一部のページネーションスクリプトには、データテーブルなどの検索機能が組み込まれています。 –