-1
I am creating a Javascript program that calculates BMI, there are fixed patients who already come with their data filled and I am putting the option to add more patients. The problem is when a new patient is created because it is not filling a part of the table "classification" I tried to create a function with "if" but this returning "Undefined", I don’t know what else to do.
The function is inside a for
function classe () {
if (imc) {
var tdClass = paciente.querySelector(".info-class")
tdClass.textContent = "Teste";
}
return;
}
var executa = classe();
Here I created another solution to get the patient’s data
var paciente = {
nome: form.nome.value,
peso: form.peso.value,
altura: form.altura.value,
gordura: form.gordura.value,
imc: calculaImc(form.peso.value, form.altura.value),
classificaocao: classe()
}
return paciente;
};
E essa outra para adicionar os novos paciente a tabela
function montaTr (paciente){
var pacienteTr = document.createElement("tr");
pacienteTr.classList.add("paciente");
pacienteTr.appendChild(montaTd(paciente.nome, "info-nome"));
pacienteTr.appendChild(montaTd(paciente.peso, "info-peso"));
pacienteTr.appendChild(montaTd(paciente.altura,"info-altura"));
pacienteTr.appendChild(montaTd(paciente.gordura, "info-gordura"));
pacienteTr.appendChild(montaTd(paciente.imc, "info-imc"));
pacienteTr.appendChild(montaTd(paciente.classificaocao, "info-class"));
return pacienteTr;
};
Puts all the code, help. Including the html part.
– Débora Castro