ArmadoDeForm.js
1.79 KB
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
function ArmarForm(data) {
document.getElementById("ArmarFormContainer").style.display="none";
document.getElementById("FormularioResultante").style.display="block";
let m = data.length;
for (let n = 0; n < m; n++) {
let padreBotones = document.getElementById("BotonesContainer");
let padreTabs = document.getElementById("TabsContainer");
let boton = document.createElement("Button");
padreBotones.appendChild(boton);
boton.setAttribute("id", "Boton" + n);
boton.setAttribute("value", n);
boton.setAttribute("class", "Botones");
boton.setAttribute("onclick", "HabilitarTab(\
document.getElementById('BotonesContainer'),\
document.getElementById('TabsContainer'),\
parseInt(this.id[this.id.length - 1])\
)");
let ancho = ((100 - (0.2 * m)) / m) + "%";
boton.style.width = ancho;
let tab = document.createElement("div");
tab.innerHTML = document.getElementById('TabCardcontainer').innerHTML;
padreTabs.appendChild(tab);
tab.style.width=ancho * m;
tab.setAttribute("id", "Tab" + n);
tab.setAttribute("class", "Tabs");
}
HabilitarTab(
document.getElementById('BotonesContainer'),
document.getElementById('TabsContainer'),
0
)
}
function HabilitarTab(bc,tc,n){
if (typeof n != "number") return console.log("El entero es invalido");
for (let it = 0; it < bc.children.length && it < tc.children.length; it++) {
if (it == n) {
bc.children[it].classList.add("BotonesActive");
tc.children[it].style.display = "block";
} else {
bc.children[it].classList.remove("BotonesActive");
tc.children[it].style.display = "none";
}
}
}