-
Notifications
You must be signed in to change notification settings - Fork 0
/
page.html
69 lines (60 loc) · 2.18 KB
/
page.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
<html>
<head>
<title>Lista de Chamada</title>
</head>
<body>
<h1> Sig@ </h1>
Novo Aluno :<input type="text" id="newName" name="StudantName" value="Lucas">
<button onclick="AddCheckBox()" id="newStudant">Add</button>
<button onclick="checkPersonInTheBox(true)" id="checkNew">Check</button>
<button onclick="checkPersonInTheBox(false)" id="checkNew">Check</button>
<h1>Alunos</h1>
<ul id="ClassRoom">
<input type="checkbox" name="Kiev Gama" value="Kiev Gama" />Kiev Gama <br>
<input type="checkbox" name="Gabriel Bandeira" value="Gabriel Bandeira" />Gabriel Bandeira<br>
<input type="checkbox" name="Junior Lima" value="Junior Lima" />Junior Lima<br>
<input type="checkbox" name="Heitor Rapela" value="Heitor Rapela" />Heitor Rapela<br>
</ul>
<br /><br />
<button onclick="checkPerson('Kiev Gama', true)">Check Kiev</button>
<button onclick="checkPerson('Kiev Gama', false)">UnCheck Kiev</button>
<button onclick="checkPerson('Lucas', true)">Check Lucas</button>
<button onclick="checkPerson('Lucas', false)">UnCheck Lucas</button>
<script>
function checkPersonInTheBox(sel)
{
var studentName = document.getElementById('newName').value;
checkPerson(studentName,sel);
}
function checkPerson(name, sel)
{
checkboxes = document.getElementsByName(name);
for(var i=0, n=checkboxes.length;i<n;i++) {
checkboxes[i].checked = sel;
}
}
function AddCheckBox()
{
// Get Name
var studentName = document.getElementById('newName').value
// Show the name
var newName = document.createElement("textName");
var t = document.createTextNode(studentName);
newName.appendChild(t);
var breakLine = document.createElement("br");
// Create CheckBox
var newCheckBox = document.createElement("INPUT");
newCheckBox.setAttribute("type", "checkbox");
newCheckBox.setAttribute("name", studentName);
var listOfStudents = document.getElementById("ClassRoom");
listOfStudents.appendChild(newCheckBox);
listOfStudents.appendChild(newName);
listOfStudents.appendChild(breakLine);
}
function hello() {
console.log("Hello");
// body...
}
</script>
</body>
</html>