Search code examples
javascripthtmlwordpressfilterwebshop

How to make a search function with dropdown?


I have a website with a lot of products I've made in Wordpress. To make it easy for my visitors, I would like to make a search function with dropdowns.

My idea is, that my visitors have to select some categories in some dropdowns, and eventually press a search button to then display products that matching, what the visitors had chosen.

These types of dropdowns I think are like thise: https://www.w3schools.com/html/tryit.asp?filename=tryhtml_elem_select


Solution

  • For that you need to create a custom dropdown and not select list. ALternatively you can use datalist

    <form action="/action_page.php" method="get">
      <input list="browsers" name="browser">
      <datalist id="browsers">
        <option value="Internet Explorer">
        <option value="Firefox">
        <option value="Chrome">
        <option value="Opera">
        <option value="Safari">
      </datalist>
    </form>