Execute function from one page to another

0

I have a question regarding my project. I have a button on an "x" page that upon clicking it checks the geolocation in Google maps (fills the inputs with the coordinates). So far so good, I need to do this function also on a page and y with the same schema: button; on click I get the value of two input fields and then mark on the map. But the map is on the "x" page and the page and " button and the script on the map in" script.js ".

I can not think of any way to do this, because I do not have very great knowledge. I saw that the possibilities in an AJAX of life would work, but I do not have much knowledge.

To help, follow the images:

I wanted your help with this question, if there is a way to do it, and an example of how to do it.

In short, it would be: run button on page and -> the function is read from a function in the script file. where is the map and the functions - > then run this function on page x and mark in google maps after location.

    
asked by anonymous 06.04.2018 / 18:56

1 answer

1

You can use LocalStorage to save the coordinates and the next page to get them. LocalStorage is a storage space in the user's browser.

Ex:

// Salva na página anterior
localStorage.setItem("latitude", "-450.56464984");
localStorage.setItem("longitude", "-38.89748914");

// Recupera na próxima página
document.getElementById("campo-latitude").innerHTML = localStorage.getItem("latitude");
document.getElementById("campo-longitude").innerHTML = localStorage.getItem("longitude");
    
06.04.2018 / 20:12