-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
118 lines (101 loc) · 3.57 KB
/
script.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
const botaoEnviarHeader = document.getElementById('submit-header');
const emailHeader = document.getElementById('email-header');
const passwordHeader = document.getElementById('password-header');
function enviaHeader(evento) {
if (emailHeader.value === 'tryber@teste.com' && passwordHeader.value === '123456') {
evento.preventDefault();
window.alert('Olá, Tryber!');
} else {
evento.preventDefault();
window.alert('Email ou senha inválidos.');
}
}
botaoEnviarHeader.addEventListener('click', enviaHeader);
const button = document.getElementById('submit-btn');
const checkbox = document.getElementById('agreement');
function desativar() {
button.disabled = true;
}
window.onload = desativar;
function ativar() {
if (checkbox.checked === true) {
button.disabled = false;
} else if (checkbox.checked === false) {
button.disabled = true;
}
}
checkbox.addEventListener('click', ativar);
const textarea = document.getElementById('textarea');
const count = document.getElementById('counter');
function counter() {
count.innerText = 500 - textarea.value.length;
}
textarea.addEventListener('keyup', counter);
function reboot(event) {
event.preventDefault();
}
button.addEventListener('click', reboot);
const main = document.querySelector('.main');
const result = document.createElement('section');
result.id = 'form-data';
const name = document.getElementById('input-name');
const lastName = document.getElementById('input-lastname');
const email = document.getElementById('input-email');
const house = document.getElementById('house');
const family01 = document.getElementById('frontend');
const family02 = document.getElementById('backend');
const family03 = document.getElementById('fullstack');
const content = document.getElementsByClassName('subject');
const radio = document.getElementsByClassName('radio');
function changeHeader() {
document.getElementById('evaluation-form').style.display = 'none';
const info01 = document.createElement('p');
info01.innerText = `Nome: ${name.value} ${lastName.value}`;
result.appendChild(info01);
const info02 = document.createElement('p');
info02.innerText = `Email: ${email.value}`;
result.appendChild(info02);
const info03 = document.createElement('p');
info03.innerText = `Casa: ${house.value}`;
result.appendChild(info03);
main.appendChild(result);
}
button.addEventListener('click', changeHeader);
function changeMain() {
const info04 = document.createElement('p');
if (family01.checked === true) {
info04.innerText = `Família: ${family01.value}`;
} else if (family02.checked === true) {
info04.innerText = `Família: ${family02.value}`;
} else if (family03.checked === true) {
info04.innerText = `Família: ${family03.value}`;
}
result.appendChild(info04);
}
button.addEventListener('click', changeMain);
function contents() {
const info05 = document.createElement('p');
const array = [];
for (let i = 0; i < content.length; i += 1) {
if (content[i].checked === true) {
array.push(content[i].value);
}
}
const frase = array.join(', ');
info05.innerText = `Matérias: ${frase}`;
result.appendChild(info05);
}
button.addEventListener('click', contents);
function rate() {
const info06 = document.createElement('p');
const info07 = document.createElement('p');
for (let i = 0; i < radio.length; i += 1) {
if (radio[i].checked === true) {
info06.innerText = `Avaliação: ${radio[i].value}`;
}
}
info07.innerText = `Observações: ${textarea.value}`;
result.appendChild(info06);
result.appendChild(info07);
}
button.addEventListener('click', rate);