Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Apr 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Don't know what part could be incorrect

    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

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    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
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow

  • #3
    Regular Coder
    Join Date
    Nov 2007
    Location
    127.0.0.1
    Posts
    348
    Thanks
    26
    Thanked 40 Times in 39 Posts
    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
    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

    Code:
    /////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
    		}

  • #4
    New to the CF scene
    Join Date
    Apr 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thank You !!

    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •