I'm having some trouble retrieving values from localStorage. I'm trying to store inputs and selects from a form and use it on another page after clicking on submit. This is what the form looks like :

Surface du terrain (Optionnel)

placeholder="Ex. 500" />

And my JS for this file :

function callme() {

let inputSurfaceDuTerrain = document.getElementById('inputSurfaceDuTerrain');

localStorage.setItem('inputSurfaceDuTerrain', inputSurfaceDuTerrain.value);

};

On my other file, the thank-you.html page, i'd like to print the input value on screen. Here are my html & JS :

window.onload = function () {

document.getElementById('inputSurfaceDuTerrain').innerText = "inputSurfaceDuTerrain, " + localStorage.getItem('inputSurfaceDuTerrain');

};

But it prints "undefined" on screen...

更多推荐