I am trying to change the contents of a paragraph to the value of a text input field on the input field's submit. The paragraph will momentarily change and then the page will refresh and the changes will be reverted. How do I keep the changes? Thank you!
Here is my code:
<!DOCTYPE html>
<html>
<body>
<form onsubmit = "myFunction()">
<input id = "input" type = "text">
</form>
<p id = "change"> This should be changed on submit</p>
<script>
function myFunction() {
document.getElementById("change").innerHTML = document.getElementById("input").value;
}
</script>
</body>
</html>