Home Blog Projects
Shivaji Varma Home Blog Projects Theme
Home Blog Programming Sum Of Two Numbers

Sum Of Two Numbers

Posted on February 8, 2014 by Edit

Short and sweet application. On submitting the form a, b values are passed to self(same page) using GET method. On reload the JS fetches values of a & b from URL using getUrlParameter Method and computes there sum.

Output (A+B):


Code

$(document).ready(function(){
	var a = getUrlParameter("a");
	var b = getUrlParameter("b");
	if(a!="" && b!=""){
		if($.isNumeric(a) && $.isNumeric(b)){
			$("#output").html(+a + +b);
		}
		else  $("#output").html("Enter only numbers.");
	}
	else $("#output").html("Please fill the input and hit add button.");
});
Tags: js
This website is made possible by displaying online advertisements to our visitors.
Please consider supporting by disabling your ad blocker.

Get new posts by email:
loading comments...

Shivaji Varma

Staff Software Engineer & Architect based in India. I build and scale cloud-based applications, contribute to open source, and share what I learn along the way.