A
A
alh_22015-12-09 14:35:06
PHP
alh_2, 2015-12-09 14:35:06

Script on js to change the city like on Biglion (the principle itself) how to do it?

There is a site, in the header of the site, the city of the visitor is determined by ip, sometimes it is incorrect. It is necessary that a person clicks on the city and selects his city from the list and all the content on the site has changed, the site is one-page. The solution is needed in js or jquery. Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2015-12-11
@alh_2

You need two lists:
- List of countries
- List of cities
1. In the first list of countries, make selected the country to which the user's city belongs.
2. In the second list, upload available cities for the selected country from the first list.
3. Set selected to the user's city.
When the page is fully loaded, the user has a list of countries, a selected country, a list of cities for the selected country, and a selected city.
- Select a neighboring city, there is no problem, from your loaded second list, he makes selected another city.
- Select another country, the user selects a neighboring country from the first list, you make an ajax request by CountryId to your service to update the second list (available cities in the selected country), the user selects a city.
After the above steps, you have a confirmed CityId, how to update the content already depends on your architecture and site operation. Here, either you write the selected city Id somewhere and refresh the page (if the user has changed his CityId), or if everything is fine with you, then simply re-request the content from your backend service for the desired CityId.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question