Reply
Javascript Quiz
Old 08-22-2004, 01:40 PM Javascript Quiz
Junior Talker

Posts: 2
Hi this is my first post, I have been trying to create a Javascript quiz for ages now and after
finally doing it, I have come up with a very annoying problem.

(you can find the quiz and code here) http://statzone.port5.com/quiz.htm

It seem's that the only "points" that get registered in the grade it method are the questions 1-10 and 90-100. If you could help me to find out the problem why these other questions aren't "working" (so to speak) that would be very much appreciated as ive tried everywhere and looked throughout all my code but still, cannot find an explanation or error in it.

Thanks for your help and time people.
dv_ccfc is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 08-23-2004, 12:14 PM
Novice Talker

Posts: 7
The problem with your script seems to be at this line:

Code:
if (Answers[89] == UserAnswers[89])
{count89 = count8 + 1}
else
{count89 = count8}
it should be count88 not count8.

I'd suggest a much easier way of going about this problem though, rather than having to create 100 variables, you can just perform a loop.

HTML Code:
<SCRIPT LANGUAGE="javascript">

function Gradeit()
{
	var Answers=new Array(2,1,3,1,4,1,2,1,3,4,3,2,4,3,1,4,2,4,1,2,2,4,3,4,3,4,1,1,3,3,2,3,4,1,1,4,2,1,1,1,4,3,4,4,3,1,2,3,3,3,1,4,2,3,2,3,3,4,2,3,4,2,1,4,1,3,1,1,3,1,2,3,4,2,1,3,3,4,3,4,1,2,3,4,3,1,1,2,3,1,4,1,4,2,2,2,2,4,2,1);
	var score=0;

	for (i=0;i<100;i++) {
		if (Answers[i] == document.forms[0].elements[i].selectedIndex) score++;
	}

	alert("You scored " + score + "%");
}
</SCRIPT>
This should work much better and save you a few headaches
jonnyj is offline
Reply With Quote
View Public Profile Visit jonnyj's homepage!
 
Old 09-05-2004, 07:09 PM
Junior Talker

Posts: 2
Thanks for the help
dv_ccfc is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Javascript Quiz
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12725 seconds with 12 queries