Numerous errors. Compare this working version to your original.
Code:
<html xmlns="http://www.w3.org/1999/xhtml">
<title>Untitled</title>
<script type="text/javascript">
function sum() {
var a=Number(document.myForm.a.value);
var b=Number(document.myForm.b.value);
alert("Total is = " +(a+b));
}
</script>
</head>
<body>
<form name="myForm" action="" method="post" onsubmit="return false">
<p>I hope this works!!!</p>
<input type="text" name="a" />
<input type="text" name="b" />
<input type="button" value="Add" onclick="sum();" style="width: 55px" />
</form>
</body>
</html>
If you put your script between [ code] and [ /code] tags (without the spaces)
it makes it easier to read, copy and test for other forum members.
Bookmarks