I need to link when i click “Submit” button to open another html page and to change text on it.
my html code
<div class="welcome">
<h2 id="welcomeHeader">Welcome to Quiz</h2>
<h3 id="nameHeader">Write Your Name</h3>
<input id="userName">
<button type="submit" onclick="start()">Let's Go!</button>
</div>
my quiz code
<div>
<h2 id="welcomeText">Hello</h2>
</div>
my JS code
let userName = document.getElementById('userName');
let nameHeader = document.getElementById('nameHeader');
let welcomeText = document.getElementById('welcomeText');
function start() {
window.location.href='quiz.html';
welcomeText.innerHTML = 'Hello ' + userName.value; + ', welcome to Quiz';
}
Code opening quiz.html page but it doesn’t rewrite text in #welcomeText?
Any help?
I tried different solutions but nothing works. I need all kind of help.