/
home
/
obinna
/
html
/
cravings
/
public
/
js
/
Upload File
HOME
var address = document.getElementById('address'); var longitude = document.getElementById('longitude'); var latitude = document.getElementById('latitude'); const add = localStorage.getItem('location') ? JSON.parse(localStorage.getItem('location')) : ''; if(add) { address.value = add.address; longitude.value = add.longitude latitude.value = add.latitude } document.querySelector('#address').addEventListener('focus', function(e){ e.target.select(); }) document.querySelector('#address').addEventListener('keyup', function(e){ if(e.target.value.length === 0) { document.getElementById('longitude').value = "" document.getElementById('latitude').value = "" } }) const populate = (location) => { address.value = location.address || address.value; longitude.value = location.longitude || longitude.value; latitude.value = location.latitude || latitude.value; } autocomplete(address).then(loc => { populate(loc); });