Answer the question
In order to leave comments, you need to log in
How to sort select from another select?
Good afternoon, there are 2 selecta:
1:
<option value="343">Адыгея</option>
<option value="344">Алтайский край</option>
<option value="345">Амурская область</option>
2:
<option value="Алтайский край">Алейск</option>
<option value="Пермский край">Александровск</option>
<option value="Алтайский край">Барнаул</option>
<option value="Алтайский край">Белокуриха</option>
Answer the question
In order to leave comments, you need to log in
after selecting in the first field, send the id of the selected element using ajax to the backend, from there you return the elements for the second select in response.
if you want purely on the frontend, then when outputting, set the class to something like class="ragion_{REGION_ID}" and then you can remove unnecessary regions
, in general, there are many different options for solving this problem
You must create in advance on the server or on the client a tree structure of regions and cities in them. Then everything will be easy to sort.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question