ArmadoDeForm.js
1.41 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
var getAncestorByAttribute = (elem,attr,val) => {
while (elem.getAttribute(attr) != val || elem == null) elem = elem.parentElement;
return elem;
}
var getDescendantByAttribute = (elem,attr,val) => {
if (elem == null || elem.getAttribute(attr) == val) return elem;
return Array.from(elem.children).reduce( (a,b) => {
let x = getDescendantByAttribute(a,attr,val);
let y = getDescendantByAttribute(b,attr,val);
return x == null ? y : x;
}, null);
}
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";
}
}
}
function Otro(otroselect){
let inputs = getAncestorByAttribute(otroselect,"class","FieldInput");
let other = getDescendantByAttribute(inputs,"class","Other");
if (otroselect.nodeName == "SELECT"){
if (otroselect.selectedOptions[0].value == "Otro") other.style.display = "block";
else other.style.display = "none";
}
else {
if (otroselect.checked) other.style.display = "block";
else other.style.display = "none";
}
}