mounty95
asked on
Javascript If Then Return Value
I am stuck on what I have a feeling is a pretty simple JS.
I have a button that when clicked does a calculation based on form fields and returns a numeric value.
I would like to add an additional field to evaluate the numeric value and return a description like "Superior" "Good" "Adequate" etc.
How do I write a separate formula to return the description by evaluating the calculated number field something like: if score less than 75 then Poor else if score between 75 and 80 then Not Adequate so on and so forth.
Thank you in advance for any help on this.
I have a button that when clicked does a calculation based on form fields and returns a numeric value.
I would like to add an additional field to evaluate the numeric value and return a description like "Superior" "Good" "Adequate" etc.
How do I write a separate formula to return the description by evaluating the calculated number field something like: if score less than 75 then Poor else if score between 75 and 80 then Not Adequate so on and so forth.
Thank you in advance for any help on this.
ASKER
What do your mean context?
I have a button that the user clicks after filling out a form. The value is returned in a textbox with id="s".
I want to evaluate the value in the textbox and return in a separate textbox a descriptor for that calculation.
I have a button that the user clicks after filling out a form. The value is returned in a textbox with id="s".
I want to evaluate the value in the textbox and return in a separate textbox a descriptor for that calculation.
Context is giving us some code and not just saying I have a button.
Why evaluate the textbox, just work out the description (using code like above) when the button is pressed.
Why evaluate the textbox, just work out the description (using code like above) when the button is pressed.
ASKER
Here is the formula that returns a value:
function calc(thisform)
{
var rf=thisform.rf.value;
var ap=thisform.ap.value;
var ts=thisform.ts.value;
thisform.s.value=math.roun d(rf+ap+ts )
How would I (in the same code) evaluate so that the value in s and a description get returned?
Sorry to be so vague.
function calc(thisform)
{
var rf=thisform.rf.value;
var ap=thisform.ap.value;
var ts=thisform.ts.value;
thisform.s.value=math.roun
How would I (in the same code) evaluate so that the value in s and a description get returned?
Sorry to be so vague.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you for your help.
function getdescription(score){
if(score<=100){getdescript
if(score<=80){getdescripti
if(score<=75){getdescripti
return getdescription
}