I have several HTML tables hided in accordions panel, I need to search into all the tables to find a row, did I miss something to deploy corresponding panel and highlight the corresponding row ?
Here is my code:
function testSearch(){
console.log("testresearch")
let input = document.getElementById('searchbar').value
input=input.toLowerCase();
let x = document.getElementsByClassName('panel');
for (i = 0; i < x.length; i++) {
if (!x[i].innerHTML.toLowerCase().includes(input)) {
x[i].style.display="none";
}
else {
x[i].style.display="list-item";
}
}
}
<input
id="searchbar"
onkeyup="testSearch()"
type="text"
name="search"
placeholder="..."
/><br />
<button class="accordion button is-light">A</button>
<div class="panel" style="">
<table class="dataframe table is-hoverable is-fullwidth clickable-table">
<tbody>
<tr>
<td>A</td>
<td>A</td>
<td>A</td>
</tr>
</tbody>
</table>
</div>
<button class="accordion button is-light">B</button>
<div class="panel" style="">
<table class="dataframe table is-hoverable is-fullwidth clickable-table">
<tbody>
<tr>
<td>B</td>
<td>B</td>
<td>B</td>
</tr>
</tbody>
</table>
</div>
The result is not what I need, I just have some changes in my HTML structure, but I need my panel to be active, and after I will need to highlight the matching input with correponding rows