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>
데이터가 페이지에 완전히로드되지 않았으므로 시도 할 수 없습니다. 데이터를 검색하고 결과를 리턴하려면 요청을 서버에 다시 게시해야합니다. 일부 페이지 매기기 스크립트에는 데이터 테이블과 같은 검색 기능이 내장되어 있습니다. –