forked from mr-robot-2008/html
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswap.html
More file actions
44 lines (43 loc) · 1 KB
/
swap.html
File metadata and controls
44 lines (43 loc) · 1 KB
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
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var x=0,y=0;
function num()
{
x = parseInt(document.getElementById("t1").value);
y = parseInt(document.getElementById("t2").value);
}
function add(){
num();
var z=x+y;
document.getElementById("t3").value = z;
}
function sub(){
num();
var z=x-y;
document.getElementById("t3").value = z;
}
function mul(){
num();
var z=x*y;
document.getElementById("t3").value = z;
}
function div(){
num();
var z=x/y;
document.getElementById("t3").value = z;
}
</script>
<title></title>
</head>
<body>
First number:<input type = "text" id ="t1"><br>
Second number:<input type = "text" id ="t2"><br>
<input type ="button" value ="ADD" onclick="add()">
<input type ="button" value ="Sub" onclick="sub()">
<input type ="button" value ="MUL" onclick="mul()">
<input type ="button" value ="DIV" onclick="div()"><br>
Result:<input type = "text" id ="t3">
</body>
</html>