CMS Filter - can a user search on one page and return the same query on a page with CMS filter search implemented?

Hi! I’m working on my company’s support pages and I have CMS filter and search successfully implemented on our browse all support page.

I’m wondering if I can allow users to search for their query on our support home page. Currently, the search in the hero of this page is just a standard site search, and ideally I’d like searching from this page to take the user to the browse all page with the query already in the URL. I’m assuming I’d need to swap this search bar to a form text input but beyond that I’m not sure what the next step is.

Webflow read only:

Thank you!

Hey @holly!

This can be done with some simple JS.

You’ll need to add this code to the /support page

      const userInput = document.getElementById('search-2');
      const form = document.querySelector('.hero-support-search.w-form');

      form.addEventListener('submit', function (e) {
        const searchInput = userInput.value;
        if (!searchInput) return;
        const queryParam = searchInput.replaceAll(' ', '+');

        let url = '/browse-support?*=' + queryParam;

        // console.log(url); // For testing
        window.location.href = url; // Uncomment this line to redirect to the constructed URL

and this code to your /browse-support page.

  window.fsAttributes = window.fsAttributes || [];
    (filterInstances) => {
      console.log('cmsfilter Successfully loaded!');
      document.getElementById('field').dispatchEvent(new Event('input', { bubbles: true }));

Note, you will have to change the text field identifier to fs-cmsfilter-field=*