У меня есть таблица с шестью TD, и в нем примерно 7000 записей. The table is filtered by six input text boxes with
six javascript codes and each code containing the desired number of corresponding td such as (td = tr.getElementsByTagName("td")[0],
(td = tr.getElementsByTagName("td")[1], (td = tr .getelementsbytagname ("td") [2] и т. Д. Чтобы избежать этой проблемы, возможно ли отфильтровать таблицу
только с одним входным ящиком вместо шести входных ящиков, но с вариантом, чтобы ввести желаемый номер TD ** [0] **, [1], < /strong> [2] < /strong>, и т. Д. и т. Д. и т. Д., Чтобы отфильтровать данные
только от TD. Спасибо < /p>
Total/Searched:
Name
Country
City
Street
House No
Neighbour
Mario Resende
Argentina
Buenos Aires
Belgrano Calle
2:3
Cristina Rodriguez
Philips Douglas
United Kingdom
London
Oxford Avenue
17:25
Sophie Loren
Ramesh Bugatapa
India
New Delhi
Golochand road
1:2
Kiran Johr
function filterTable() {
var input, filter, table, tr, td, i, txtValue;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
table = document.getElementById("myTable");
tr = table.getElementsByTagName("tr");
rowsFound =[];
for (i = 0; i < tr.length; i++) {
td = tr.getElementsByTagName("td")[4];
if (td) {
txtValue = td.textContent || td.innerText;
// EDIT Check for match at beginning of string
// if (txtValue.toUpperCase().indexOf(filter) > -1) {
if (txtValue.toUpperCase().indexOf(filter) == 0) {
tr.style.display = "";
rowsFound.push(1)
} else {
tr.style.display = "none";
}
}
}
У меня есть таблица с шестью TD, и в нем примерно 7000 записей. The table is filtered by six input text boxes with six javascript codes and each code containing the desired number of corresponding td such as (td = tr[i].getElementsByTagName("td")[b][0][/b];), (td = tr[i].getElementsByTagName("td")[b][1][/b];), (td = tr [i] .getelementsbytagname ("td") [2];) и т. Д. Чтобы избежать этой проблемы, возможно ли отфильтровать таблицу только с одним входным ящиком вместо шести входных ящиков, но с вариантом, чтобы ввести желаемый номер TD ** [0] **, [1], < /strong> [2] < /strong>, и т. Д. и т. Д. и т. Д., Чтобы отфильтровать данные только от TD. Спасибо < /p> Total/Searched:
Name Country City Street House No Neighbour
Mario Resende Argentina Buenos Aires Belgrano Calle 2:3 Cristina Rodriguez
Philips Douglas United Kingdom London Oxford Avenue 17:25 Sophie Loren
Ramesh Bugatapa India New Delhi Golochand road 1:2 Kiran Johr
function filterTable() { var input, filter, table, tr, td, i, txtValue; input = document.getElementById("myInput"); filter = input.value.toUpperCase(); table = document.getElementById("myTable"); tr = table.getElementsByTagName("tr"); rowsFound =[]; for (i = 0; i < tr.length; i++) { td = tr[i].getElementsByTagName("td")[4]; if (td) { txtValue = td.textContent || td.innerText; // EDIT Check for match at beginning of string // if (txtValue.toUpperCase().indexOf(filter) > -1) { if (txtValue.toUpperCase().indexOf(filter) == 0) { tr[i].style.display = ""; rowsFound.push(1) } else { tr[i].style.display = "none"; } } }