Javascript Quiz need some help

This is a discussion on "Javascript Quiz need some help" within the JavaScript Forum section. This forum, and the thread "Javascript Quiz need some help are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Mar 3rd, 2008, 21:18
Junior Member
Join Date: May 2004
Location: Kansas City
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Javascript Quiz need some help

Hi All,

I would like some help with this quiz I've downloaded. I really like the way it works, my only wish is to have the 100% quizer redirect to another webpage. Whomever did not make 100% will be sent to redo the quize and I think it does that already.

It can be that once an alert box comes up to congratulate them, they then hit ok and it redirect them to the _self site with a new page. I try searching for ways to put link on an alert box but I don't think that's possible. Anyway if you could help that would be excellent. Thanks.

Here is the link to the source codes.

http://javascript.internet.com/misce...oice-quiz.html
Attached Files
File Type: zip multi-quiz.zip (617 Bytes, 6 views)
Reply With Quote

  #2 (permalink)  
Old Mar 4th, 2008, 08:48
Reputable Member
Join Date: Nov 2007
Location: India
Posts: 150
Blog Entries: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Javascript Quiz need some help

I haven't looked at the source files but you will have to insert the below snippet in the appropriate place.
Code: Select all
if(totalscore=="100%")
{
window.location = "http://www.google.com/";
}
else
{
alert("Please take the quiz again");
window.reload();
}
Last Blog Entry: Cross browser nuisance (Feb 11th, 2008)
Reply With Quote
  #3 (permalink)  
Old Mar 4th, 2008, 19:57
Junior Member
Join Date: May 2004
Location: Kansas City
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Javascript Quiz need some help

I thought that this might be an appropriate place, but it's not working.

if(pc < 100) {
if(confirm(alertMsg))
resetQuiz(false);
{
window.location = "http://www.google.com/";
}

else
return false;
} else {
alert(alertMsg);
}

Where should my snippet goes?
Reply With Quote
  #4 (permalink)  
Old Mar 6th, 2008, 15:47
Junior Member
Join Date: May 2004
Location: Kansas City
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Javascript Quiz need some help

Here is a snipplet of codes, what it does if if you take a quiz whether you pass the quiz or not
you get an alert box.

If you get 100% an alert box pop ups with only the ok button.
If you missed 1 on the quiz an alert box pop up with OK and Cancel. If you hit ok the page automatically refreshes to retake the quize. If you hit cancel nothing happen.

How can I make a 100% alert box show a URL, is it possible? If not can an alert box OK buttons goes to redirect page? If so, what do I need to do for that to happen?

function showScore() {
if(answered != answers.length) {
alert ("You have not answered all of the questions yet!");
return false;
}
questionCount = answers.length;
correct = 0;
incorrect = 0;
for(i=0;i<questionCount;i++) {
if(useranswers[i] == answers[i])
correct++;
else
incorrect++;
}
pc = Math.round((correct / questionCount) * 100);
alertMsg = "You scored " + correct + " out of " + questionCount + "\n\n";
alertMsg += "You correctly answered " + pc + "% of the questions! \n\n";
if(pc == 100)
alertMsg += response[0];
else if(pc >= 90)
alertMsg += response[1];
else if(pc >= 70)
alertMsg += response[2];
else if(pc > 50)
alertMsg += response[3];
else if(pc >= 40)
alertMsg += response[4];
else if(pc >= 20)
alertMsg += response[5];
else if(pc >= 10)
alertMsg += response[6];
else
alertMsg += response[7];
if(pc < 100) {
if(confirm(alertMsg))
resetQuiz(false);
else
return false;
} else {
alert(alertMsg);
}
}

Please advise thank you in advance.
Reply With Quote
Reply

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript dharvesh JavaScript Forum 4 Oct 21st, 2007 01:28
quiz! alexgeek Webforumz Cafe 16 Sep 11th, 2007 19:01
Interactive DVD with quiz Paula Graphics and 3D 3 Oct 4th, 2006 13:38
Want code n template of online quiz s_mazhar PHP Forum 2 Aug 31st, 2006 11:45


All times are GMT. The time now is 01:11.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43