Jump to content

Recommended Posts

I'm having difficulty with this function. I'm using jquery. The number in #cfp will be anything from 1 to 11,000. My function below should display the word Excellent, Good, Average or Poor depending on the number. But it doesn't work. It doesn't seem to be comparing the vars correctly and will show two words at times. What am I doing wrong? Thanks.

 

To test it I've made the var rating

var rating = '3000';

but it still doesn't quite work. Am I doing it right or is there a better way to do this comparison?

 

function rating(){
var rating = $("#cfp").text();

if(rating < '2500'){
var myDiv1 = document.getElementById("rating");
myDiv1.appendChild(document.createTextNode("Excellent"));
}else if(rating > '2501' && rating < '6999'){
var myDiv1 = document.getElementById("rating");
myDiv1.appendChild(document.createTextNode("Good"));
}else if(rating > '7000' && rating < '10000'){
   	var myDiv1 = document.getElementById("rating");
  	myDiv1.appendChild(document.createTextNode("Average"));
}else if(rating  > '10001'){
   	var myDiv1 = document.getElementById("rating");
   	myDiv1.appendChild(document.createTextNode("Poor"));
}
};

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.