Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 30th, 2012  |  syntax: None  |  size: 0.52 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Why can't I use onsubmit to change innerHTML?
  2. <html>
  3. <head>
  4. <script type="text/javascript">
  5. function changeTo(text){
  6.     document.getElementById("p1").innerHTML=text;
  7. }
  8. </script>
  9. </head>
  10. <body>
  11. <h1 style="text-align:center;">Change text in an element</h1>
  12. <!--
  13. <form onsubmit="changeTo('Hello World');">
  14. <input type="submit" />
  15. </form>
  16. -->
  17. <input type="button" onclick="changeTo('Hello World');" />
  18. <p id="p1">text</p>
  19.  
  20. </body>
  21. </html>
  22.        
  23. <form onsubmit="changeTo('Hello World');return false;">
  24. <input type="submit" />
  25. </form>