Creating An Online Quiz
Score As A Percentage
To convert the score that the 'player' has achieved to a percentage we use the 'maxposs' variable as set in quiz2.js . Using simple math we then divide the score attained, (runnintotal) by the maximum possible score (maxposs) and then multiply the answer by 100.
alert((((Number(runnintotal))/(Number(maxposs)))*100)+'%');
I have possibly gone a little over the top with the brackets but I wanted to ensure that the math was carried out in the correct order.
Below I've spaced the command out a little more to make the Math clearer.
(   ( Number(runnintotal) ) / ( Number(maxposs) )   ) * 100
<<< LAST PAGE   NEXT PAGE >>>
BACK TO HOME PAGE

Valid HTML 4.01!