Scroll naar boven
document.addEventListener("DOMContentLoaded", function () { const table = document.querySelector("#items-table table"); if (!table) return; const rows = table.querySelectorAll("tbody tr"); const rowsPerPage = 50; const totalPages = Math.ceil(rows.length / rowsPerPage); const pagination = document.querySelector("#table-pagination"); if (!pagination) return; let currentPage = 1; function showPage(page) { currentPage = page; const start = (page - 1) * rowsPerPage; const end = start + rowsPerPage; rows.forEach(function (row, index) { if (index >= start && index < end) { row.style.display = ""; } else { row.style.display = "none"; } }); renderPagination(); } function renderPagination() { pagination.innerHTML = ""; /* Previous button */ const previousButton = document.createElement("button"); previousButton.textContent = "← Vorige"; previousButton.disabled = currentPage === 1; previousButton.addEventListener("click", function () { if (currentPage > 1) { showPage(currentPage - 1); } }); pagination.appendChild(previousButton); /* Page numbers */ for (let i = 1; i <= totalPages; i++) { const pageButton = document.createElement("button"); pageButton.textContent = i; if (i === currentPage) { pageButton.classList.add("active"); } pageButton.addEventListener("click", function () { showPage(i); }); pagination.appendChild(pageButton); } /* Next button */ const nextButton = document.createElement("button"); nextButton.textContent = "Volgende →"; nextButton.disabled = currentPage === totalPages; nextButton.addEventListener("click", function () { if (currentPage < totalPages) { showPage(currentPage + 1); } }); pagination.appendChild(nextButton); } /* Start on page 1 */ showPage(1); });