K
K
kerop2018-11-29 19:09:37
JavaScript
kerop, 2018-11-29 19:09:37

How to make a search on the site through several selects?

The site has a search form that consists of two selects and a "Search" button.
When a button is clicked, Javascript generates a link, depending on which value was selected, and the user is redirected to the corresponding page.
simple example:

<select name="location">
 <option value="los-angeles">Los Angeles</option>
 <option value="new-york">New York</option>
</select>

<select name="type">
 <option value="newspaper">Newspaper</option>
 <option value="magazine">Magazine</option>
</select>

The user can select one, two or none.
For example, you can get a link example.com/location/new-york/type/newspaper or example.com/type/magazine
But, as I understand it, when a link is generated by Javascript, search robots cannot see it, so the final addresses are not considered reachable from the search page.
There is something similar to Avito.
How can search be organized differently so that the summary pages are reachable from the search page and still make it easy for users to search?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrew, 2018-11-29
@iCoderXXI

All possible combinations should be pre-generated and placed on the page in the form of links hidden by styles, showing the desired one when choosing something.

S
sim3x, 2018-11-29
@sim3x

Make everything links - after loading the page, style it with js.
Leave it as it is - make quick categories links. For PC themes: office, gaming, ....

V
Viktor S, 2019-02-07
@vitek112

Good afternoon! Found a solution? I’m also interested in this question on Wordpress, but I’m not strong in programming languages, drag and dropom can collect the maximum logic through the admin panel)) maybe there is a plugin, I found Calculated Fields Form but I can’t catch up yet how to implement it there.
You need to create a search:
1 form = car brand
2 form = car model
3 selection button = go to the page
selection separately is not possible, also prohibiting the display of the list from form 2 until you select something in form 1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question