JavaScript Tutorial JJavaScript Examples CSS Tutorial HTML Tutorial About Us

Kid Math


This is a simple JavaScript calculator that performs the addition of two numbers. Besides that, we create a JavaScript function RandomFn() that load two numbers when the web page is loaded in the browser. Next, we create the following JavaScript to add the two numbers and save it as kidmath.js. We can launch this JavaScript using the following statement.

<script type="text/javascript" src="kidmath.js"></script>
function myFunction() {
var number1;
var number2;

number1=document.getElementById('num1').innerHTML ;
number2=document.getElementById('num2').innerHTML;
var sum=parseInt(number1)+parseInt(number2);
document.getElementById('ans').textContent="The sum of two numbers= "+sum;

}

Addition of Two Numbers

Please calculate the sum of two numbers.

Number 1:

Number 2:

Calculate the sum of two numbers






Copyright©2008 Dr.Liew Voon Kiong. All rights reserved |Contact|Privacy Policy