-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestscript.html
More file actions
100 lines (93 loc) · 3.26 KB
/
Copy pathtestscript.html
File metadata and controls
100 lines (93 loc) · 3.26 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<!--link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous"-->
<!--script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script-->
<!--script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" crossorigin="anonymous"></script-->
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<title>Document</title>
<link href="styles.css" rel="stylesheet">
<style>
#my-input{
width: 200px;
height: 50px;
font-size: 25px;
}
#result{
width: 50px;
height: 50px;
}
</style>
</head>
<body>
<input id="my-input">
<input id="but" type="button" onclick="javascript:run();">
<div id="result"> </div>
<script>
var x = name(350,210);
function name(a,b) {
return a + b;
}
console.log(x);
alert(x);
function run(){
var el = document.getElementById("my-input");
if (el){
var age = parseInt(el.value);
if (!isNaN(age)){
document.getElementById("result").innerHTML = "<b>Your age: </b>" +el.value;
} else{
alert("Error");
}
} else {
alert("no element");
}
}
</script>
<input id="number1">
<select name="" id="operation" required>
<option value="">Select operator</option>
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
<option value="%">%</option>
</select>
<input id="number2">
<input id="but" type="button" onclick="javascript:calculate();" value="Calculate">
<div id="result2"> </div>
<script>
function calculate(){
var el1 = document.getElementById("number1");
var el2 = document.getElementById("number2");
var op = document.getElementById("operation");
if (el1 && el2 && op){
var left = parseInt(el1.value);
var right = parseInt(el2.value);
var operator = parseInt(op.value);
if (!isNaN(left) && !isNaN(right)){
switch (operator){
case "+": document.getElementById("result2").innerHTML = "<b>Sum is: </b>" +(left + right);
break;
case "-": document.getElementById("result2").innerHTML = "<b>Sum is: </b>" +(left - right);
break;
default: alert("Wrong operation");
}
} else{
alert("Error");
}
} else {
alert("no element");
}
}
</script>
</body>
</html>