我正在尝试为我正在创建的网站创建搜索栏。但是,它似乎不起作用。目前,我已对搜索栏的所有数据进行了硬编码,但稍后将导入一个文件,该文件将自动导入数据。
我有一个来自其他类的名为search_book()的函数,但需要调用BrowseRow类以提取数据。
search_book(){
var filter, get_book, get_row, a, txtvalue, i;
let input = document.getElementById('SearchBar').value;
filter = input.toLowerCase();
get_row = document.getElementbyID("BrowseRow.tr");
get_book = document.getElementsbyTagName("BrowseRow.td.title");
for (i = 0; i < get_book.length; i++){
a = get_book[i].getElementsByTagName("a")(0);
txtvalue = a.textContent || a.innerText;
if(txtvalue.toUpperCase().indexOf(filter) > -1){
get_book.style.display = " ";
}
else{
get_book.style.display = "none";
}
}
class BrowseRow extends Component {
// Make the post request, return 10 exchanges
// for each exchange, populate textbook title, class name, edition, and price
// link next table button with another render, but with page++
render() {
return (
<tr>
<td>{this.props.title}</td>
<td>{this.props.author}</td>
<td>{this.props.edition}</td>
<td>{this.props.class}</td>
<td>{this.props.price}</td>
</tr>
);
}
}