What are various events performed on JavaScript? Explain with example?



1.       onClick
2.      ondblClick
3.      onLoad
4.     onUnload
5.      onMouseOver
6.     onMouseOut

Example :
<html>
<head><title>Events</title>
<script language="Javascript">
function sum(x)
{
a=parseInt(x.n.value);
b=parseInt(x.m.value);
c=a+b;
alert("Sum = "+c);
}
function sub(x)
{
a=parseInt(x.n.value);
b=parseInt(x.m.value);
d=a-b;
alert("Sub = "+d);
}
function mul(x)
{
a=parseInt(x.n.value);
b=parseInt(x.m.value);
e=a*b;
alert("mul = "+e);
}
function div(x)
{
a=parseInt(x.n.value);
b=parseInt(x.m.value);
f=a/b;
alert("div = "+f);
}
function mod(x)
{
a=parseInt(x.n.value);
b=parseInt(x.m.value);
g=a%b;
alert("mod = "+g);
}
</script>
</head>
<body>
<form>
Enter Value a <input type="text"name="n">
Enter Value b <input type="text"name="m"><br>
<input type="button" value="+" onclick="sum(this.form)"><br>
<input type="button" value="-" ondblclick="sub(this.form)"><br>
<input type="button" value="*" onmouseover="mul(this.form)"><br>
<input type="button" value="/" onmouseout="div(this.form)"><br>
<input type="button" value="mod" onunload="mod(this.form)"><br>
</form>
</body>
</html>

Comments

Popular posts from this blog

Write a program to add two number using inline function in C++?

Traversing of elements program with algorithm and Flowchart