Introduction
Here we take an example in which when we click on the button the addition will be performed. For this follow these steps:
Step1: First we carate a button control like this, here we call a function which we will be discussed later:
- <input id="btnAddition" type="button"
- value="Add" onclick="Add()" />
- var values = function (a, b) {
- this.a = a;
- this.b =b;
- };
- function Add() {
- var addition = new values(2,3);
- alert(addition.a+addition.b);
- }
Here we create an object and return the addition of the two numbers. This function is called on the onclick event of the button so when we click on the button an alert box will appear like this:


Dhanik SahniPosted Jul 9, 2013, 8:59 AM
Nice.