-
Notifications
You must be signed in to change notification settings - Fork 1
/
pedidoDom.js
90 lines (62 loc) · 2.45 KB
/
pedidoDom.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
function createTable() {
const numberTable = document.getElementById('numberTable').value;
const typeChoop = document.querySelector('select[name="typeChoop"]').value;
const typeBebidas = document.querySelector('select[name="typeBebidas"]').value;
const typeFood = document.querySelector('select[name="typeFood"]').value;
const confirmation = confirm(`Cadastrar mesa ${numberTable}?`);
if (confirmation) {
Swal.fire(
'Pedido concluido!',
'Seus itens foram adicionados',
'success'
)
const itensTable = {};
itensTable.table = numberTable
itensTable.choop = typeChoop;
itensTable.bebidas = typeBebidas;
itensTable.food = typeFood;
// CODIGO MODIFICADO 21/06/2023 INSERINDO ELEMENTO DENTRO DE TABELA
// let tableBody = document.getElementById("tableBody");
// let tableTd = document.querySelector(".tableTd");
// const td = document.createElement("td")
// const tipoBebida = document.createTextNode(typeBebidas);
// td.appendChild(tipoBebida);
// tableBody.appendChild(tableTd)
// tableTd.appendChild(td)
// td.innerHTML = tipoBebida.value;
let tableBody = document.getElementById("tableBody");
const td = document.createElement("td");
const tipoBebida = document.createTextNode(typeBebidas);
td.appendChild(tipoBebida);
tableBody.appendChild(td);
// Limpar os campos
document.getElementById('numberTable').value=""
document.getElementById('typeChoop').value=""
document.getElementById('typeBebidas').value=""
document.getElementById('typeFood').value=""
}
}
function closeTable(){
const removeNumber = document.getElementById('numberTable').value;
const removeTable = document.getElementById(`mesa-${removeNumber}`);
const confirmationRemove = confirm(`Deseja remover a mesa ${removeNumber}?`);
if (confirmationRemove && removeTable) {
removeTable.remove();
Swal.fire(
'Mesa Removida!',
'Mesa fechada com sucesso',
'success'
)
document.getElementById('numberTable').value = "";
}else{
alert("Mesa invalida!!")
}
}
function description(){
const description= document.getElementById('description')
const createTextarea= document.createElement("textarea")
createTextarea.id="textDescription"
createTextarea.rows=2
createTextarea.cols= 33
description.appendChild(createTextarea)
}