-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic_calculator.html
50 lines (40 loc) · 1.27 KB
/
basic_calculator.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
<input id ="num1" value = "">
<input id = "num2" value = "">
<button onclick="resultt()">+</button>
<button onclick="result1()">*</button>
<button onclick="result2()">/</button>
<button onclick="result3()">-</button>
<!-- var total = input 1 (num1 ) + input 2 (num2 values ) -->
<p id ="result">Display Result</p>
<script>
var box1 = document.getElementById("num1")
var box2 = document.getElementById("num2")
var res = document.getElementById("result")
value1= Number(box1.value)
value2 = Number(box2.value)
console.log(value1, value2 )
function resultt(){
value1= Number(box1.value)
value2 = Number(box2.value)
var total = value1+value2
result.textContent = total
}
function result1(){
value1= Number(box1.value)
value2 = Number(box2.value)
var total_mul = value1*value2
result.textContent = total_mul
}
function result2(){
value1= Number(box1.value)
value2 = Number(box2.value)
var total_div = value1 / value2
result.textContent = total_div
}
function result3(){
value1= Number(box1.value)
value2 = Number(box2.value)
var total_sub = value1-value2
result.textContent = total_sub
}
</script>