-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharithmetic.html
64 lines (52 loc) · 1.91 KB
/
arithmetic.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
56
57
58
59
60
61
62
63
64
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Arithmatic</title>
<link rel="stylesheet" href="style.css">
<script>
function calc() {
var n1 = parseInt(document.getElementById("n1").value);
var n2 = parseInt(document.getElementById("n2").value);
var oper = document.getElementById("operation").value;
if (oper === 'add'){
var n2 = document.getElementById("result").value = n1 + n2;
}
if (oper === 'sub'){
var n2 = document.getElementById("result").value = n1 - n2;
}
if (oper === 'mul'){
var n2 = document.getElementById("result").value = n1 * n2;
}
if (oper === 'div'){
var n2 = document.getElementById("result").value = n1 / n2;
}
}
</script>
</head>
<body>
<label>Enter First Number:</label>
<input type="text" id="n1"></br> <br>
<label>Enter Second Number:</label>
<input type="text" id="n2"> </br> <br>
<label>add/sub/mul/div:</label>
<input type="text" id="operation"> </br> <br>
<!-- <select name="" id="operation">
<option value="add">Add</option>
<option value="sub">Sub</option>
<option value="mul">Mul</option>
<option value="div">Div</option>
</select> -->
<button onclick="calc();">=</button>
<input type="text" id="result">
<!-- <div class="container">
<input type="number" id="firstInput">
<input type="number" id="secondInput">
<button>Mul.</button>
<h1>Result</h1>
</div> -->
<script src="script.js"></script>
</body>
</html>