This repository has been archived by the owner on Jun 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
62 lines (62 loc) · 2.16 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
<!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>Javascript Basics</title>
<script language="javascript" type="text/javascript">
function changeToGreen() {
document.getElementById("task1").style.color = "green"
}
function checkAge() {
var age = document.checkAgeForm.age.value
alert(age > 65)
}
function add() {
var a = parseInt(document.calcForm.num1.value)
var b = parseInt(document.calcForm.num2.value)
document.getElementById("output").innerHTML = a + b
}
function subtract() {
var a = parseInt(document.calcForm.num1.value)
var b = parseInt(document.calcForm.num2.value)
document.getElementById("output").innerHTML = a - b
}
function multiply() {
var a = parseInt(document.calcForm.num1.value)
var b = parseInt(document.calcForm.num2.value)
document.getElementById("output").innerHTML = a * b
}
function divide() {
var a = parseInt(document.calcForm.num1.value)
var b = parseInt(document.calcForm.num2.value)
document.getElementById("output").innerHTML = a / b
}
</script>
</head>
<body>
<div>
<h1 id="task1">Task 1</h1>
<button onclick="changeToGreen()">Green</button>
</div>
<hr>
<form name="checkAgeForm">
<h1>Task 2</h1>
<input type="number" name="age">
<button onclick="checkAge()">Check</button>
</form>
<hr>
<form name="calcForm">
<h1>Task 3</h1>
<input type="number" name="num1">
<input type="number" name="num2">
<button type="button" onclick="add()">Add</button>
<button type="button" onclick="subtract()">Subtract</button>
<button type="button" onclick="multiply()">Multiply</button>
<button type="button" onclick="divide()">Divide</button>
<h3>Output:</h3>
<p id="output"></p>
</form>
</body>
</html>