I'm trying to make a form where the user input is stored as local storage data. When the user submits, the data gets stored and the browser opens another html file.
What happens is: the data gets stored in the browser's LocalStorage in the first page only, so when I try to retrieve it in the second page nothing happens.
<script>
function x() {
let y = document.getElementById("txt").value;
localStorage.setItem("a",y);
return false;
}
</script>
<body>
<form action="x1.html" >
<input type="text" id="txt"/>
<input type="submit" value="click" onclick="x();"/>
</form>
</body>
<body>
Ciaoo <span id="z"></span> !!
<script>
document.getElementById("z").InnerHTML=localStorage.getItem(a);
</script>
</body>
I expect the output of page 2 to show LocalStorage content in the mark. There's no error messages.