Answer the question
In order to leave comments, you need to log in
How to implement when issuing js one issue another?
Is there a ready-made code
https://jsfiddle.net/tty37u7m/
that gives you the location of your city?
it gives out like this
<p>Страна: <span id="country"></span></p>
<p>Край(обл.): <span id="state"></span></p>
<p>Город: <span id="city"></span></p>
<p>Адрес: <span id="address"></span></p>
<p>Широта: <span id="latitude"></span></p>
<p>Долгота: <span id="longitude"></span></p>
if ($city == 'Казань') {
echo 'Наш телефон для Казани 1111111';
} elseif ($city == 'Москва') {
echo 'Телефон для Москвы 2222222';
} elseif ($city == 'Санкт-Петербург') {
echo 'Телефон для Санкт-Петербурга 3333333';
} elseif ($city == 'Тюмень') {
echo 'Телефон для Тюмени 4444444';
} else {
echo 'Ваш город ' . $city . '.';
Answer the question
In order to leave comments, you need to log in
You can add a field
and a function
$.getJSON(GEOCODING).done(function(location) {
$('#country').html(location.results[0].address_components[5].long_name);
$('#state').html(location.results[0].address_components[4].long_name);
$('#city').html(location.results[0].address_components[2].long_name);
$('#address').html(location.results[0].formatted_address);
$('#latitude').html(position.coords.latitude);
$('#longitude').html(position.coords.longitude);
getPhone(location.results[0].address_components[2].long_name);
})
function getPhone(city){
$.('#phonenumber').innerHTML = (city=='Казань'? '1111111111':city='Москва'?'2222222222':'...';
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question