My search bar appear but not working, whenever I type in the keyword, the page will still be the same without showing any result
20:51 05 Jan 2023

I've been trying to make a search bar for my e-commerce web site for the user to find their favorite product.

I had to use JavaScript to make the search bar workable but it still not working, the search bar appears but it can't be used, whenever you type in something, the page will still be the same without changing and sorting for the keyword.

My JavaScript:

const search = () => {
    const searchbox = document.getElementById("search-item").value.toUpperCase();
    const storeitems = document.getElementById("game-list")
    const product = document.querySelectorAll("pro")
    const pname = storeitems.getElementsByTagName("h5")

    for (var i = 0; i < pname.length; i++) {
        let match = product[i].getElementsByTagName('h5')[0];

        if (match) {
            let textvalue = match.textContent || match.innerHTML

            if (textvalue.toUpperCase().indexOf(searchbox) > -1) {
                product[i].style.display = "";
            } else {
                product[i].style.display = "none";
            }
        }
    }
}
 
Developer : CD PROJEKT RED
CYBERPUNK

$85

javascript html css search