-
Notifications
You must be signed in to change notification settings - Fork 0
/
logic.js
53 lines (34 loc) · 1.54 KB
/
logic.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
document.querySelector('#boton2').addEventListener('click', saveAnimal);
//document.querySelector('#boton3.botons').addEventListener('click', saveAnimal)
document.querySelector('#boton3').addEventListener('click', addUpdateAnimal);
drawAnimalTable();
function saveAnimal() {
var sMicrochip = document.querySelector('#Microchip').value,
species = document.querySelector('#Species').value,
sSex = document.querySelector('#Sex').value,
sSize = document.querySelector('#Size').value,
sPotentDangerous = document.querySelector('#PotentDangerous').value,
sNeighborhood = document.querySelector('#Neighborhood').value;
addAnimalToSystem(sMicrochip, species, sSex, sSize, sPotentDangerous, sNeighborhood);
drawAnimalTable();
}
function drawAnimalTable() {
var list = getAnimalList(),
tbody = document.querySelect('$ejemplo tbody');
tbody.innerHTML = '';
for (var i = 0; i < list.length; i++) {
var row = tbody.insertRow(i);
var nameCell = row.insertCell(0);
nameCell.innerHTML = list[i].microchip;
tbody.appendChild(row);
}
}
function addUpdateAnimal() {
var sRace = document.querySelector('#species').value,
sOwner = document.querySelector('#owner').value,
sAdress = document.querySelector('#adres').value,
sPicture = document.querySelector('#picture').value,
sOwnerMicrochip = document.querySelector('#micro').value;
var animalObj = findAnimal(sOwnerMicrochip);
addUpdateAnimal(animalObj, sRace, sOwner, sAdress, sPicture);
}