日期:2014-05-16 浏览次数:20373 次
<html>
<head><title>Simple Add Function</title>
<script language="javascript">
function AddFun()
{
num1 = document.getElementById("num1").value;
num2 = document.getElementById("num2").value;
sum =parseFloat(num1)+parseFloat(num2);
alert(sum);
}
</script>
</head>
<body>
<input name="num1" id="num1" type="text" value=""/>
+
<input name="num2" id="num2" type="text" value=""/>
<input name="equals" type="button" value=" = " onclick="AddFun()">
</body>
</html>