Skip to content Skip to sidebar Skip to footer

Transferring Variables Across Html Pages

I am taking in an input from a text box in one HTML page and saving it to local storage using this function. function writeMail(emailInput){ console.log(emailInput); localStorage.s

Solution 1:

For you to be able to manipulate the contents of HTML, you need to modify the DOM node specifically. In this specific case you should have an id attribute on the <td>and then use the innerHTML property of that node to set the desired value.

i.e.:

<tdid="xpto"></td>

then on the code:

let theEmail = localStorage.getItem('emailInput');
document.getElementById("xpto").innerHTML = theEmail;

You should also set that code inside of a function that is called once the document has finished loading, so something like:

JAVASCRIPT:

functiongo(){
   let theEmail = localStorage.getItem('emailInput');
   document.getElementById("xpto").innerHTML = theEmail;
}

HTML:

<bodyonload="go()">

Post a Comment for "Transferring Variables Across Html Pages"