lundi 3 décembre 2018

conditional statement returning value in input box

I have the following. input box type number for a number rating of the risk likelihood input box type number for a number rating of the risk Consequence. input box type number for a number rating of the risk rating which is predetermined by a matrix with values ranging from 1-9. input box for the rating of the risk level.

what i need is,

if the value in the the risk rating area is between 1 & 2 the risk level area should display "low"

if the value in the the risk rating area is between 3 & 6 the risk level area should display "medium"

if the value in the the risk rating area is between 7 & 9 the risk level area should display "high".

how do i write in an input box if the above mentioned conditions have been met.

the following is my code:

function getRiskRate(z){
    var z=document.getElementById("Risk_rating").value;
        return(z);

}
getRiskRate();

function Rate(z){
    var z=document.getElementById("Risk_rating").value;
    getRiskRate();
        if(z>1 || z<=2){
            document.getElementById('mySeverity').value='Low';
            } else if(z>2 || z<=6){
                document.getElementById('mySeverity').value='Medium';
                } else if (z>6 || z<=9){
                    document.getElementById('mySeverity').value='High';
                        }else{
                            document.getElementById('mySeverity').value='value not defined';
                        }
}
Rate();

i am still a beginner, please bare with me.

Aucun commentaire:

Enregistrer un commentaire