I am new to HTML and JS and I am trying to get a value from an input in a page called second.html and send it to a p tag in a page called third.html.
Not sure whether this is something possible but on second.html I have some input-elements in which once some information is written I want to press a button and then that would take me to another page (third.html), in which the value that I got from the input in the second.html would be used in a p tag. I have been able to get the input value and move to the third.html page, however, assigning the value to the p-element is where I am failing. This is the code:
second.html
</head>
<body>
<h1>Second page</h1>
<label for="ticket">ticket:</label>
<input
type="text"
id="ticket2"
name="ticket"
required
minlength="4"
maxlength="8"
size="10"
/>
<button onclick="ticket()">Click me</button>
</body>
JavaScript:
function ticket() {
let ticketp3 = document.querySelector("#specials p").innerHTML;
let valueticket = document.getElementById("ticket2").value;
ticketp3 = valueticket;
parent.location = "third.html";
}
third.html
<div id="specials">
<h1>thrid page</h1>
<p></p>
</div>