-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
63 lines (51 loc) · 1.64 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
<!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>Document</title>
</head>
<body>
<div>
<label for="age">firstname</label>
<input type="text" id="firstname" required>
<input type="text" id="lastname" required>
<input type="text" id="age" required>
<button id="submit" > Submit </button>
<div id="result"></div>
<div id="eligible"></div>
<div id="not_eligible"></div>
<div>dlsfo</div>
</div>
</body>
<script>
let firstname,lastname,age,result,eligible,not_eligible ;
function details()
{
firstname=document.getElementById("firstname").value;
lastname=document.getElementById("lastname").value;
age=document.getElementById("age").value;
result = "Your name is " + firstname + lastname + "and your age" + age;
document.getElementById("result").innerHTML = result
console.log(result);
condition()
}
document.getElementById("submit").addEventListener("click", details)
function condition()
{
if(age>18){
eligible = "You are eligible";
document.getElementById("eligible").innerHTML = eligible
document.body.style.backgroundColor='green';
}
else
{
not_eligible = "You are not eligible";
document.getElementById("not_eligible").innerHTML = not_eligible
document.body.style.backgroundColor='red';
}
}
condition();
</script>
</html>