-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
88 lines (76 loc) · 1.83 KB
/
main.js
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
var text;
var html = "";
var inds;
var keys;
const brothers = [
"Please choose",
"John",
"Brad",
"Alia",
];
for (let i = 0; i < brothers.length; i++) {
html += `<option>${brothers[i]}</option>`;
}
document.getElementById("selec").innerHTML = html;
const John = {
name: "John",
surname: "Onix",
age: 37,
MaritalStatus: "Single",
job: "Physical Education Teacher",
MaritalStatus: "Married",
Child: 2,
};
const Brad = {
Name: "Brad",
Surname: "Onix",
Age: 37,
Job: "Physical Education Teacher",
MaritalStatus: "Married",
Child: 1,
};
const Alia = {
Name: "Alia",
Surname: "Onix",
Age: 25,
Job: "Artist",
MaritalStatus: "Single",
};
function selec(element) {
text = element.options[element.selectedIndex].value;
inds = element.selectedIndex;
console.log(inds);
var bild = document.getElementById("bb").textContent = text;
if (!inds == 0) {
switch (inds) {
case 1:
var ekl = "";
for (const [key, value] of Object.entries(John)) {
ekl += `<li> <b>${key}:</b> <span>${value}</span></li>`;
}
document.getElementById("p").innerHTML = ekl;
break;
case 2:
var ekl = "";
for (const [key, value] of Object.entries(Brad)) {
ekl += `<li> <b>${key}:</b> <span>${value}</span></li>`;
}
document.getElementById("p").innerHTML = ekl;
break;
case 3:
var ekl = "";
for (const [key, value] of Object.entries(Alia)) {
ekl += `<li> <b>${key}:</b> <span>${value}</span></li>`;
}
document.getElementById("p").innerHTML = ekl;
break;
default:
break;
}
} else {
var warn = "Please Choose...";
document.getElementById(
"p"
).innerHTML = `<li style="color:red; font-size:20px; font-weight:bold;">${warn}</li>`;
}
}