dimanche 9 août 2020

Value of checkbox if checked [duplicate]

  function myFunction(){
     var x = document.getElementById('cough').value + document.getElementById('cold').value +
            document.getElementById('fever').value + document.getElementById('breathlessness').value +
            document.getElementById('loss of senses').value + document.getElementById('sore throat').value +
           document.getElementById('none').value + document.getElementById('diabeties').value +
            document.getElementById('heart disorder').value + document.getElementById('lung disorder').value +
            document.getElementById('kidney disorder').value + document.getElementById('hypertension').value + 
           document.getElementById('no disorder').value;
            
    
    if (x==0) {
        document.getElementById('result').innerText = "No Risk";
    
    } else if(x>0 & x<=4) {
        document.getElementById('result').innerText = "Low Risk";
    } else if(x>4 & x<9) {
        document.getElementById('result').innerText = "Medium Risk"; 
    }else {
        document.getElementById('result').innerText = "High Risk";       
}}
document.getElementById('analyse').addEventListener('click',(e)=>{
e.preventDefault();

})

**I'm trying to get the output of checkbox if checked. i've assigned values to it so that whenever its checked it returns value as 0 1 2 3 in html. By storing it into a variable x it should return result based on input.This one always shows High risk **




Aucun commentaire:

Enregistrer un commentaire