passing a value from the textbox to a different html page

Try adding this on the homepage.js It will listen when the user clicks the link and change the href before requesting the next page.

function onClickHandler(e){
    document.querySelector('a').href = "createUser.html?name=" + document.getElementById('username').value; 
}

window.onload = function() {
    document.querySelector('a').addEventListener('click', onClickHandler);
}

Add this at the end of createUser.js so it will fill the input after the window has loaded

window.onload = onLoadHandler;

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top