Jump to content

Page disappears


Recommended Posts

When I run the following code and submit, the page flashes (about 1 second) with the modified html and then disappears. Is it something to do with the function?

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8" /><title>Learning Java Script</title></head><body><form id="choice" onsubmit="decision();">Logo or text? <input type="text" id="c1"><input type="submit" value="Enter"></form><p id="display"></p><script>function decision() {var answer = document.getElementById("choice").value;var replace = document.getElementById("display");if (answer === "text") {replace.innerHTML = document.createTextNode("<p>some text</p>");}else {replace.innerHTML = document.createTextNode("<img src="gr8oz2.0.png" alt="">");}return false;}</script></body></html>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...