Reputation: 11
I am trying to access an element id of an HTML page from another page. I have seen other solutions but none have worked so far.
For example, if this is One.html
<input id="a" type="text"></input>
<p id="demo"></p>
I am trying to access the element id 'a' from Two.html to get the value that has been inputted using `
var thing = document.getElementById('a').value;
document.getElementById('demo').innerHTML = "the value is" + " " + thing;
Upvotes: 0
Views: 12913
Reputation: 142
sorry I don't have enough reputation to leave this as a comment but just a heads up, input tags are standalone tags.
Example:
<body>
<input type="text" id="a" />
</body>
Upvotes: 1
Reputation: 330
you can use localStorage
for example in firstpage.html you save data with
var thing = document.getElementById('a').value;
localStorage.something = thing ;
then in your seconpage.html you can use it by
document.getElementById("demo").innerHTML=localStorage.something;
Upvotes: 3