0

Is there any way to set the result_page of a Low Search form dynamically via JS? The use case is:

I've got a job search form. It has a select field for category, which produces a URL such as /search?category=1&keywords=foo. For SEO, it'd be much better for the URL to be /search/category_name?keywords=foo. Is there any way to change the form action using JS, when someone changes that select field?

Thanks loads for any pointers!

0

You wouldn't even need JS to achieve this. You can add a select element that populates the result_page parameter, like so:

<select name="result_page">
    <option value="search">Select category</option>
    {exp:channel:categories style="linear" ... }
        <option value="search/{category_url_title}">
            {category_name}
        </option>
    {/exp:channel:categories}
</select>

But, as far as I know, forms will not be POSTed by search engines, and therefore search results pages will also not be indexed. Your argument to add the category URL title to the URI might not be valid.

1
  • Ah very cool. And that's a good point re: search engines. We might actually need to rethink this part of the site... Thanks for your help! Oct 4 '17 at 13:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.