-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
34 lines (26 loc) · 1.05 KB
/
script.js
File metadata and controls
34 lines (26 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const searchInput = document.getElementById('substr');
const select = document.querySelector('.search select');
const allCells=document.querySelectorAll('.table .cell')
const searchButton = document.querySelector('.search button');
const quantity=document.getElementById('quantity');
function handleSearchButtonClick() {
const selectValue = select.value;
const cells = document.querySelectorAll('.table .cell[data-header="' + selectValue + '"]');
let totalMatches = 0;
const searchValue = searchInput.value.toLowerCase();
allCells.forEach(function(cell) {
cell.style.color = '#E4E4E4';
});
cells.forEach(function(cell) {
const cellText = cell.textContent.toLowerCase();
if (cellText.includes(searchValue)) {
cell.style.color = 'red';
totalMatches += 1;
}
});
if (totalMatches==0)
quantity.textContent = "ничего не найдено";
else
quantity.textContent = totalMatches;
}
searchButton.addEventListener('click', handleSearchButtonClick);