-
Notifications
You must be signed in to change notification settings - Fork 0
/
exo67.html
105 lines (83 loc) · 3.56 KB
/
exo67.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
102
103
104
105
<!DOCTYPE html>
<html>
<head>
<style>
.input {
margin: 1.5%;
}
#countries {
margin: 1%;
}
#qcm {
margin-top: 2.5%;
}
</style>
<script>
correctAnswers = [['japan', 'tokyo'], ['germany', 'berlin'], ['algeria', 'alger'], ['norway', 'oslo'], ['emirates', 'abou dabi']];
correctAnswersUser = [0, 0, 0, 0, 0];
function copyString() {
input1 = document.getElementById('input1').value;
document.getElementById('input2').value = input1;
}
function getSelectValue() {
value = document.getElementById('countries').value;
document.getElementById('input3').value = value;
document.getElementById('input4').value = value;
}
function qcm(question, id) {
number = 0
if (document.getElementById(question).value.toLowerCase() == correctAnswers[id-1][1]) {
correctAnswersUser[id-1] = 1;
}
else {
correctAnswersUser[id-1] = 0;
}
for(i = 0; i < correctAnswersUser.length; i++) {
number += correctAnswersUser[i];
}
document.getElementById('correctAnswers').innerHTML = number;
}
</script>
</head>
<body>
<div id="forms">
<form id="form1">
<label for="input1">Input 1</label>
<input class="input form-control" type="text" id="input1" name="input1" oninput="copyString()"><br>
<label for="input2">Input 2</label>
<input class="input form-control" type="text" id="input2" name="input2"><br>
<label for="countries">Sélectionnez un pays</label>
<select name="countries" id="countries" onchange="getSelectValue()">
<option value="Paris">France</option>
<option value="Washington">USA</option>
<option value="Ottawa">Canada</option>
<option value="Tokyo">Japon</option>
<option value="Stockholm">Suède</option>
</select>
<label for="input3">Input 3</label>
<input class="input form-control" type="text" id="input3" name="input3">
</form>
<form id="form2">
<label for="input4">Input 4</label>
<input class="input form-control" type="text" id="input4" name="input4">
</form>
<label for="qcm">
<h2>QCM</h2>
</label>
<div id="qcm">
<label for="japan">Capitale du Japon</label>
<input class="input form-control" type="text" id="japan" name="1" onblur="qcm(this.id, this.name)"><br>
<label for="germany">Capitale de l'Allemagne</label>
<input class="input form-control" type="text" id="germany" name="2" onblur="qcm(this.id, this.name)"><br>
<label for="algeria">Capitale de l'Algérie</label>
<input class="input form-control" type="text" id="algeria" name="3" onblur="qcm(this.id, this.name)"><br>
<label for="norway">Capitale de la Norvège</label>
<input class="input form-control" type="text" id="norway" name="4" onblur="qcm(this.id, this.name)"><br>
<label for="emirates">Capitale des Emirats</label>
<input class="input form-control" type="text" id="emirates" name="5"
onblur="qcm(this.id, this.name)"><br><br>
<label for="correctAnswers">Réponses correctes : </label><label id="correctAnswers"></label>
</div>
</div>
</body>
</html>