-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathjscalculator.html
55 lines (51 loc) · 2.13 KB
/
jscalculator.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<html>
<head>
<title></title>
<script>
function Addition()
{
var firstnumber = document.getElementById("txtfirstnumber").value;
var secondnumber = document.getElementById("txtsecondnumber").value;
var lblresult = document.getElementById("lblresult");
var result= parseInt(firstnumber)+parseInt(secondnumber);
lblresult.innerHTML=result;
}
function Substraction()
{
var firstnumber = document.getElementById("txtfirstnumber").value;
var secondnumber = document.getElementById("txtsecondnumber").value;
var lblresult = document.getElementById("lblresult");
var result= parseInt(firstnumber)- parseInt(secondnumber);
lblresult.innerHTML=result;
}
function Multiplication()
{
var firstnumber = document.getElementById("txtfirstnumber").value;
var secondnumber = document.getElementById("txtsecondnumber").value;
var lblresult = document.getElementById("lblresult");
var result= parseInt(firstnumber)*parseInt(secondnumber);
lblresult.innerHTML=result;
}
function divison()
{
var firstnumber = document.getElementById("txtfirstnumber").value;
var secondnumber = document.getElementById("txtsecondnumber").value;
var lblresult = document.getElementById("lblresult");
var result= parseInt(firstnumber)/parseInt(secondnumber);
lblresult.innerHTML=result;
}
</script>
</head>
<body>
<span>Enter first number:</span>
<input id="txtfirstnumber" type="text" >
<span>Enter second number:</span>
<input id="txtsecondnumber" type="text" >
<br><br>
<input type="button" value="Addition" onclick="Addition()">
<input type="button" value="Substraction" onclick="Substraction()">
<input type="button" value="Multiplication"onclick= "Multiplication()">
<input type="button" value="divison" onclick="divison()">
<br><br>
<span>result:</span><label id="lblresult">
</body>