Here I leave what I did, the only thing I can't do is, let's say that when selecting croup and fever I get the possible covid alert but if I don't select either of them I get Unknown diagnosis, that's where I have the problem since Apparently it is not taking the names that I indicate in the if in case the person does not select flu and fever, I do not know if I made myself understood but I want that when sectioning those two I get possible covid, but if not, I get Diagnosis unknown thanks
function valida() {
var num1 = document.getElementById("fiebre").value;
var num2 = document.getElementById("gripa").value;
var num1 = document.getElementById("ardor").value;
var num2 = document.getElementById("espalda").value;
if ((fiebre == "fiebre") && (gripa == "gripa")) {
alert('Posible covid');
} else {
alert('Diagnostico desconocido');
}
}
<form method="get" action="prueba1" name="form1">
Prueba diagnostica Covid-19 <br>
Gripa: <input type="checkbox" name="gripa" id="gripa" value="gripa"><br>
Fiebre: <input type="checkbox" name="fiebre" id="fiebre" value="fiebre"><br>
Ardor de estomago: <input type="checkbox" name="ardor" id="ardor" value="ardor"><br>
Dolor de espalda: <input type="checkbox" name="espalda" id="espalda" value="espalda"><br>
<input type="button" value="Diagnostico" onclick="valida()"><br>
</form>
My suggestion to validate
inputs
the typecheck
is to check if they are selected or not usingtrue
orfalse
, so you don't have to know what value they have.Your validation would look like this: