-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclientes.js
36 lines (32 loc) · 1.29 KB
/
clientes.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
// clientes.js
document.addEventListener('DOMContentLoaded', () => {
const form = document.getElementById('formregistro');
const pfCampos = document.getElementById('pf-campo');
const pjCampos = document.getElementById('pj-campo');
const personTypeRadios = document.querySelectorAll('input[name="personType"]');
const clientList = document.getElementById('clients');
// Mostrar/ocultar campos com base no tipo de pessoa
personTypeRadios.forEach(radio => {
radio.addEventListener('change', function() {
if (this.value === 'pf') {
pfCampos.style.display = 'block';
pjCampos.style.display = 'none';
} else {
pfCampos.style.display = 'none';
pjCampos.style.display = 'block';
}
});
});
// Adicionar cliente à lista
form.addEventListener('submit', function(event) {
event.preventDefault();
// Resetar o formulário após adicionar
form.reset();
pfCampos.style.display = 'block';
pjCampos.style.display = 'none';
personTypeRadios[0].checked = true;
});
// Inicialmente exibe campos de Pessoa Física
pfCampos.style.display = 'block';
pjCampos.style.display = 'none';
});