-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
101 lines (65 loc) · 1.77 KB
/
index.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<select id ="opt">
<option>Addition</option>
<option>Subtraction</option>
<option>Multiplication</option>
<option>Divsion</option>
</select>
<input type="text" id="num1">
<input type="text" id="num2">
<button id="btn" onclick="total()">Go, Cry Go!</button>
<h1 id="tot"></h1>
</body>
</html>
<script type="text/javascript">
function total() {
var num1 = parseFloat(document.getElementById('num1').value);
var num2 = parseFloat(document.getElementById('num2').value);
var opt = document.getElementById('opt').value;
if (opt == "Addition" ) {
var gtotal = (num1 + num2);
var tot = document.getElementById('tot');
tot.innerHTML = gtotal;
}
if (opt == "Subtraction" ) {
var gtotal = (num1 - num2);
var tot = document.getElementById('tot');
tot.innerHTML = gtotal;
}
if (opt == "Multiplication" ) {
var gtotal = (num1 * num2);
var tot = document.getElementById('tot');
tot.innerHTML = gtotal;
}
if (opt == "Divsion" ) {
var gtotal = (num1 / num2);
var tot = document.getElementById('tot');
tot.innerHTML = gtotal;
}
}
/*function varia() {
function hello() {
alert("Welcome to javascript");
}
var nm = document.getElementbyId('#nnm').val();
var aa = nm.val();
alert(aa);
}*/
/*var i = 2;
var m = 3;
var mm = i + m;
alert(mm);
//var jj = document.getElementbyId('hh');
//jj.innerHTML = mm;*/
/*<input type="text" name="ainz" id="nnm">
<button onclick="varia()">Click for box</button>
<button onclick="hello()">Click for pop</button>
<h1 id="hh"></h1>
*/
</script>