Web Analytics Made Easy -
StatCounter Calculating a score print different variables - CodingForum

Announcement

Collapse
No announcement yet.

Calculating a score print different variables

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Calculating a score print different variables

    i have a working quiz at long last when you click the calculate score button

    <input type="button" value="Calculate Score" onClick="CalculateScore()">

    it outputs the results in a text box

    nobr>Your Score <input type="text" name="totalscore" size="4"></nobr>

    how on earth do i grade it eg:
    if score is <30 print not very good
    30><50 good score
    >80 very good score

    does this go in the button code?

    Not sure at all here what to do

  • #2
    you could use IF statements

    example...
    Code:
    if(score < 30)
    {
    
     alert('Not Very Good');
    
    }
    elseif((score >= 30) && (score < 50))
    {
    
     alert('Good');
    
    }
    elseif(score >= 50)
    {
    
     alert('Very Good');
    
    }
    else
    {
    
     alert('An error Occured while calculating your score');
    
    }
    hopefully this will get you on your way.

    Comment

    Working...
    X