
Untitled
By: a guest on
Jun 30th, 2012 | syntax:
None | size: 0.52 KB | hits: 15 | expires: Never
Why can't I use onsubmit to change innerHTML?
<html>
<head>
<script type="text/javascript">
function changeTo(text){
document.getElementById("p1").innerHTML=text;
}
</script>
</head>
<body>
<h1 style="text-align:center;">Change text in an element</h1>
<!--
<form onsubmit="changeTo('Hello World');">
<input type="submit" />
</form>
-->
<input type="button" onclick="changeTo('Hello World');" />
<p id="p1">text</p>
</body>
</html>
<form onsubmit="changeTo('Hello World');return false;">
<input type="submit" />
</form>