Jump to content

postoak

Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by postoak

  1. 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>
×
×
  • Create New...