I have a series of checkboxes where the user must select several options and each option increments one or more variables.
// Variáveis das características citopáticas
var hipercromasia = document.getElementById("hipercromasia");
var cromatina_grosseira = document.getElementById("cromatina_grosseira");
var queratinizacao = document.getElementById("queratinizacao");
var cariomegalia = document.getElementById("cariomegalia");
var binucleacao = document.getElementById("binucleacao");
var coilocito = document.getElementById("coilocito");
// Variáveis que armazenam os checkboxes selecionados
var ASCUS = [];
var ASCH = [];
var LSIL = [];
var HSIL = [];
// Verifica os critérios citológicos
if (hipercromasia.checked) {
ASCUS++;
ASCH++;
}
if (cromatina_grosseira.checked) {
HSIL++;
}
if (queratinizacao.checked) {
LSIL++;
HSIL++;
}
if (cariomegalia.checked) {
HSIL++;
ASCUS++;
}
if (binucleacao.checked) {
HSIL++;
ASCH++;
}
if (coilocito.checked) {
ASCUS++;
LSIL++;
}
alert(ASCUS + ASCH + LSIL + HSIL);
The problem occurs when I try to sum the result of the variables to later make the percentage and so on.
For example: If I select "Hyperchromasia" and "Chromatin", it returns me 21, not 3.
How do I sum these variables together?