Sum Of Two Numbers

Posted on February 8, 2014 by

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):



Fork Download

	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.");

loading comments...