...

View Full Version : Don't know what part could be incorrect



resource4us
04-20-2008, 07:35 AM
I picked up the quiz script from:
http://www.javascriptkit.com/script/cut180.shtml

I have created the following files and used the above script to the best of my knowledge. But alas, it is not working.

http://www.resource4us.net/p/mme/

lesson1.js
quiztest.htm
lesson1results.htm

I have also added a 2nd typical form at the bottom of the lesson1results.htm that corresponds with:
lesson1error.html
lesson1success.html
lesson1message1.txt
lesson1message2.txt

Upon answering the questions and clicking on the 'Check My Answers' button it SHOULD go to the lesson1results.htm and grade the quiz but it simply does nothing. I have searched for my error until my eyes are bogging out. Could someone please take a look at the source code and let me know what I've done wrong?

Thank you,

resource

shyam
04-20-2008, 08:39 AM
you have two forms... but, you should have only one and the name must be set to myquiz and the names of the radio buttons must be question1, question2...etc not 1_1, 1_2... once you change these 2 things it works like a charm

tagnu
04-20-2008, 10:37 AM
Oops bad timing :(
anyways, some more explanations:

2 Points:
1. Name of the form in your script and the javascript it different.
2. Names of the radio buttons are different.

Also, your radio button naming convention is like "1_1", "1_2", "1_3" etc which is not correct according W3C conventions (http://www.w3.org/TR/REC-html40/types.html#type-cdata)


ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").

Either you should change those in your form. Or make the following changes:

1. quiztest.htm
search and replace
all: "1_
to: "q1_

2. lessons1.js



/////Don't edit beyond here//////////////////////////

function gradeit(){
var incorrect=null
for (q=1;q<=totalquestions;q++){
var thequestion=eval("document.lesson1.q1_"+q)
for (c=0;c<thequestion.length;c++){
if (thequestion[c].checked==true)
actualchoices[q]=thequestion[c].value
}

if (actualchoices[q]!=correctchoices[q]){ //process an incorrect choice
if (incorrect==null)
incorrect=q
else
incorrect+="/"+q
}

resource4us
04-20-2008, 10:38 AM
You were absolutely right...it's working now...what a relief !!

P.S....the other form isn't interfering either so it's purpose if fulfilled too.

Thanks again !

resource4us



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum