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 10 of 10

Thread: Script problem

  1. #1
    New to the CF scene
    Join Date
    Jan 2004
    Location
    Welland, Ontario, Canada
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Script problem

    I am just learning javascript. I downloaded the new quiz to use on my website.

    It works on my html editor, when I open it in my browser, but when I uploaded to my server, the question page displays, but the results page will not display.

    I uploaded to public_html. When that didn't work, I moved the 3 files to a "docs" directory and changed the path of the "quiz" file to reflect that. Still would not work.

    Moved all 3 files back to public_html where they still sit, not linked from my index.html page.

    any suggestions or maybe I did something wrong.

    thanks
    catfisher

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Welcome to the forums.

    Could we get a URL so that we can see the code of the already uploaded page? It would be far easier to take a look at that way. Words like "the new quiz" imply that you're talking about a specific one. I have no idea which one that is.

  • #3
    New to the CF scene
    Join Date
    Jan 2004
    Location
    Welland, Ontario, Canada
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is the js code page. The URL won't help, because it is not linked to index_html because it doesn't work. Do you want to see the other 2 pages ( the acutal quiz and the results page) as well?

    catfisher


    /***********************************************
    * JavaScriptKit.com Multiple Choice Quiz Script (http://www.javascriptkit.com)
    * Copyright 2003 JavaScript Kit- http://www.javascriptkit.com
    * This notice and footnote must stay intact for use
    * Visit JavaScript Kit (http://www.javascriptkit.com/) for full source code
    ***********************************************/

    //Enter total number of questions:
    var totalquestions=20

    //Enter the solutions corresponding to each question:
    var correctchoices=new Array()
    correctchoices[1]='d' //question 1 solution
    correctchoices[2]='d' //question 2 solution
    correctchoices[3]='c' //question 3 solution
    correctchoices[4]='b' //question 4 solution
    correctchoices[5]='d' //question 5 solution
    correctchoices[6]='b' //question 6 solution
    correctchoices[7]='d' //question 7 solution
    correctchoices[8]='b' //question 8 solution
    correctchoices[9]='a' //question 9 solution
    correctchoices[10]='b' //question 10 solution
    correctchoices[11]='c' //question 11 solution
    correctchoices[12]='b' //question 12 solution
    correctchoices[13]='c' //question 13 solution
    correctchoices[14]='b' //question 14 solution
    correctchoices[15]='d' //question 15 solution
    correctchoices[16]='c' //question 16 solution
    correctchoices[17]='d' //question 17 solution
    correctchoices[18]='b' //question 18 solution
    correctchoices[19]='d' //question 19 solution
    correctchoices[20]='c' //question 20 solution


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

    function gradeit(){
    var incorrect=null
    for (q=1;q<=totalquestions;q++){
    var thequestion=eval("document.myquiz.question"+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
    }
    }

    if (incorrect==null)
    incorrect="a/b"
    document.cookie='q='+incorrect
    if (document.cookie=='')
    alert("Your browser does not accept cookies. Please adjust your browser settings.")
    else
    window.location="results.htm"
    }


    function showsolution(){
    var win2=window.open("","win2","width=200,height=350, scrollbars")
    win2.focus()
    win2.document.open()
    win2.document.write('<title>Solution</title>')
    win2.document.write('<body bgcolor="#FFFFFF">')
    win2.document.write('<center><h3>Solution to Quiz</h3></center>')
    win2.document.write('<center><font face="Arial">')
    for (i=1;i<=totalquestions;i++){
    for (temp=0;temp<incorrect.length;temp++){
    if (i==incorrect[temp])
    wrong=1
    }
    if (wrong==1){
    win2.document.write("Question "+i+"="+correctchoices[i].fontcolor("red")+"<br>")
    wrong=0
    }
    else
    win2.document.write("Question "+i+"="+correctchoices[i]+"<br>")
    }
    win2.document.write('</center></font>')
    win2.document.write("<h5>Note: The solutions in red are the ones to the questions you had incorrectly answered.</h5><p align='center'><small><a href='http://www.javascriptkit.com' target='_new'>JavaScript Kit quiz script</a></small>")
    win2.document.close()
    }

  • #4
    Regular Coder
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes please. It all fits together like a puzzle piece.

    Oh, and don't use Frontpage. It's absolute garbage, and messes up people's code all the time. Dreamweaver is better, but hand-coding is the best.

  • #5
    New to the CF scene
    Join Date
    Jan 2004
    Location
    Welland, Ontario, Canada
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok, I should have known that. Ha Ha. I believe the files are ok, I think it has something to do with where it is sitting on my server.

    (PS) I don't use any WSIWYG Editors. I hand code all my pages with the help of Note Tab. K?

    catfisher

    <html>

    <head>
    <title>JavaScriptKit.com Multiple Choice Quiz Script</title>

    <style>
    .qheader{
    font:bold 14px Arial;
    }

    .qselections{
    font:normal 13px Arial;
    }
    </style>

    <script src="quizconfig.js">
    </script>

    <script>

    /***********************************************
    * JavaScriptKit.com Multiple Choice Quiz Script (http://www.javascriptkit.com)
    * Copyright 2003 JavaScript Kit- http://www.javascriptkit.com
    * This notice and footnote must stay intact for use
    * Visit JavaScript Kit (http://www.javascriptkit.com/) for full source code
    ***********************************************/

    var actualchoices=new Array()
    document.cookie="ready=yes"
    </script>

    </head>

    <a href="http://www.downtimewitness.com/members/catfisherf" target="_blank"><img src="stamp.gif" width="133" height="26" border="0" align="top"
    hspace="5" vspace="5" alt="This Site Monitored by Downtime Witness"></a>

    <body bgcolor="#FFFFFF">

    <!--Comments on configuring quiz script-->
    <!--Change the questions below any way you want, but make note of the following:-->
    <!--1) Perserve the <FORM> tags -->
    <!--2a) Inside each radio button, use the VALUE attribute to denote each question's choices: "a", "b", "c" etc.-->
    <!--2b) Inside each radio button, use the NAME attribute to denote which question the button belongs to ("question1", "question2" etc-->
    <!--3) Script supports unlmited # of questions. Be sure to edit .js file to enter corresponding solutions-->

    <p align="center">

    <form method="POST" name="myquiz">

    <font face="Times New Roman, Times, Serif" size="6"><big><big><center>Nutrition Quiz</center></big></big></font></p>

    <table width="720" align="center" border="3" bordercolor="#b22222" cellpadding="10" cellspacing="0">
    <tr>
    <td>
    <div class="qheader">
    1) <font face="Times New Roman, Times, Serif" color="#008000">
    How many milligrams of Calcium are absorbed from a 1000mg. capsule of <i>Coral Calcium</i>?</font></font></div>
    <div class="qselections">
    <input type="radio" value="a" name="question1">a) 50 mg.<br>
    <input type="radio" value="b" name="question1">b) 600 mg.<br>
    <input type="radio" value="c" name="question1">c) 1000 mg.<br>
    <input type="radio" value="d" name="question1">d) 8 mg.<br>
    </div>

    <br>

    <div class="qheader">
    2) <font face="Times New Roman, Times, Serif" color="#008000">
    In 1900 the Protein content of wheat was 90%. What is is now?</font></font></div>
    <div class="qselections">
    <input type="radio" value="a" name="question2">a) 50%<br>
    <input type="radio" value="b" name="question2">b) 75%<br>
    <input type="radio" value="c" name="question2">c) 25%<br>
    <input type="radio" value="d" name="question2">d) 9%<br>
    </div>

    <br>

    <div class="qheader">
    3) <font <font face="Times New Roman, Times, Serif" color="#008000">
    What is the shiny coating is on most drug and supplement tablets?
    </font></font></div>
    <div class="qselections">
    <input type="radio" value="a" name="question3">a) Plastic<br>
    <input type="radio" value="b" name="question3">b) Sugar<br>
    <input type="radio" value="c" name="question3">c) Shellac<br>
    <input type="radio" value="d" name="question3">d) Guar Gum<br>
    </div>

    <br>

    <div class="qheader">
    4) <font face="Times New Roman, Times, Serif" color="#008000">
    What were the sales for prescription and over the counter drugs <u>just for digestive problems</u> last year?</font></font></div>
    <div class="qselections">
    <input type="radio" value="a" name="question4">a) 1 Billion US<br>
    <input type="radio" value="b" name="question4">b) 12 Billion US<br>
    <input type="radio" value="c" name="question4">c) 6 Billion US<br>
    <input type="radio" value="d" name="question4">d) 500 Million US<br>
    </div>

    <br>

    <div class="qheader">
    5) <font face="Times New Roman, Times, Serif" color="#008000">
    How many North Americans suffer from heartburn and other digestive problems?</font></font></div>
    <div class="qselections">
    <input type="radio" value="a" name="question5">a) 20,000,000<br>
    <input type="radio" value="b" name="question5">b) 35,000,000<br>
    <input type="radio" value="c" name="question5">c) 5,000,000<br>
    <input type="radio" value="d" name="question5">d) 65,000.000<br>
    </div>

    <br>

    <div class="qheader">
    6) <font face="Times New Roman, Times, Serif" color="#008000">
    What is the ideal pH level for a body to function optimally?</font></font></div>
    <div class="qselections">
    <input type="radio" value="a" name="question6">a) 4.0<br>
    <input type="radio" value="b" name="question6">b) 7.0<br>
    <input type="radio" value="c" name="question6">c) 2.5<br>
    <input type="radio" value="d" name="question6">d) 6.0<br>
    </div>

    <br>

    <div class="qheader">
    7) <font face="Times New Roman, Times, Serif" color="#008000">
    What is the rate for getting Cancer in a year?</font></font></div>
    <div class="qselections">
    <input type="radio" value="a" name="question7">a) 1 in 10<br>
    <input type="radio" value="b" name="question7">b) 1 in 5<br>
    <input type="radio" value="c" name="question7">c) 1 in 15<br>
    <input type="radio" value="d" name="question7">d) 1 in 3<br>
    </div>

    <br>

    <div class="qheader">
    8) <font face="Times New Roman, Times, Serif" color="#008000">
    What percentage of children born in 2000 will become diabetic?</font></font></div>
    <div class="qselections">
    <input type="radio" value="a" name="question8">a) 10%<br>
    <input type="radio" value="b" name="question8">b) 30%<br>
    <input type="radio" value="c" name="question8">c) 25%<br>
    <input type="radio" value="d" name="question8">d) 5%<br>
    </div>

    <br>

    <div class="qheader">
    9) <font face="Times New Roman, Times, Serif" color="#008000">
    What temperature kills food enzymes?</font></font></div>
    <div class="qselections">
    <input type="radio" value="a" name="question9">a) 118&deg; F.<br>
    <input type="radio" value="b" name="question9">b) 212&deg; F.<br>
    <input type="radio" value="c" name="question9">c) 133&deg; F.<br>
    <input type="radio" value="d" name="question9">d) 168&deg; F.<br>
    </div>

    <br>

    <div class="qheader">
    10) <font face="Times New Roman, Times, Serif" color="#008000">
    How many glasses of water with a pH value of 10 do you have to drink to neutralize 1 can of soda?</font></font></div>
    <div class="qselections">
    <input type="radio" value="a" name="question10">a) 10<br>
    <input type="radio" value="b" name="question10">b) 32<br>
    <input type="radio" value="c" name="question10">c) 7<br>
    <input type="radio" value="d" name="question10">d) 63<br>


    </div>

    <br>

    <div class="qheader">
    11) <font face="Times New Roman, Times, Serif" color="#008000">
    How many teaspoons of sugar in a can of soda?</font></font></div>
    <div class="qselections">
    <input type="radio" value="a" name="question11">a) 5<br>
    <input type="radio" value="b" name="question11">b) 1<br>
    <input type="radio" value="c" name="question11">c) 10<br>
    <input type="radio" value="d" name="question11">d) 9<br>
    </div>

    <br>

    <div class="qheader">
    12) <font face="Times New Roman, Times, Serif" color="#008000">
    How many premature deaths occur annually from the consumption of Trans Fatty Acids?</font></font></div>
    <div class="qselections">
    <input type="radio" value="a" name="question12">a) 100,000<br>
    <input type="radio" value="b" name="question12">b) 30,000<br>
    <input type="radio" value="c" name="question12">c) 40,000<br>
    <input type="radio" value="d" name="question12">d) 15,000<br>
    </div>

    <br>

    <div class="qheader">
    13) <font face="Times New Roman, Times, Serif" color="#008000">
    What is the annual income of the Health/Pharmaceutical Industry?</font></font></div>
    <div class="qselections">
    <input type="radio" value="a" name="question13">a) 500 Million US<br>
    <input type="radio" value="b" name="question13">b) 800 Million US<br>
    <input type="radio" value="c" name="question13">c) 1 Trillion US<br>
    <input type="radio" value="d" name="question13">d) 300 Million US<br>
    </div>

    <br>

    <div class="qheader">
    14) <font face="Times New Roman, Times, Serif" color="#008000">
    How many different prescription drugs does the typical heart disease patient take home from the hospital?</font></font></div>
    <div class="qselections">
    <input type="radio" value="a" name="question14">a) 27<br>
    <input type="radio" value="b" name="question14">b) 9<br>
    <input type="radio" value="c" name="question14">c) 15<br>
    <input type="radio" value="d" name="question14">d) 6<br>
    </div>

    <br>

    <div class="qheader">
    15) <font face="Times New Roman, Times, Serif" color="#008000">
    What happens when animals are put on a human diet?</font></font></div>
    <div class="qselections">
    <input type="radio" value="a" name="question15">a) Their lifespan is cut by 135%<br>
    <input type="radio" value="b" name="question15">b) Their weight increases by 164%<br>
    <input type="radio" value="c" name="question15">c) They develop the same diseases as humans<br>
    <input type="radio" value="d" name="question15">d) All of the above<br>
    </div>

    <br>

    <div class="qheader">
    16) <font face="Times New Roman, Times, Serif" color="#008000">
    How long does it take for your immune system to recover after drinking just one can of soda?</font></font></div>
    <div class="qselections">
    <input type="radio" value="a" name="question16">a) 15 Minutes<br>
    <input type="radio" value="b" name="question16">b) 1 Day<br>
    <input type="radio" value="c" name="question16">c) 4 Hours<br>
    <input type="radio" value="d" name="question16">d) 12 Hours<br>
    </div>

    <br>

    <div class="qheader">
    17) <font face="Times New Roman, Times, Serif" color="#008000">
    What along with soda consumption has risen alarmingly over the last 50 years?</font></font></div>
    <div class="qselections">
    <input type="radio" value="a" name="question17">a) Cancer<br>
    <input type="radio" value="b" name="question17">b) Diabetes<br>
    <input type="radio" value="c" name="question17">c) Arthritis<br>
    <input type="radio" value="d" name="question17">d) All of the above<br>
    </div>

    <br>

    <div class="qheader">
    18) <font face="Times New Roman, Times, Serif" color="#008000">
    What causes more deaths annually than the Second World War and the Vietnam War?</font></font></div>
    <div class="qselections">
    <input type="radio" value="a" name="question18">a) Automobile Accidents<br>
    <input type="radio" value="b" name="question18">b) Prescription Drugs<br>
    <input type="radio" value="c" name="question18">c) Natural Disasters<br>
    <input type="radio" value="d" name="question18">d) Heart Disease<br>
    </div>

    <br>

    <div class="qheader">
    19) <font face="Times New Roman, Times, Serif" color="#008000">
    What major nutrient is missing from our food and soil?</font></font></div>
    <div class="qselections">
    <input type="radio" value="a" name="question19">a) Selenium<br>
    <input type="radio" value="b" name="question19">b) Beta Glucan<br>
    <input type="radio" value="c" name="question19">c) Magnesium<br>
    <input type="radio" value="d" name="question19">d) All of the above<br>
    </div>

    <br>

    <div class="qheader">
    20) <font face="Times New Roman, Times, Serif" color="#008000">
    What is the fastest growing industry?</font></font></div>
    <div class="qselections">
    <input type="radio" value="a" name="question20">a) Drug Companies<br>
    <input type="radio" value="b" name="question20">b) Food Manufacturing<br>
    <input type="radio" value="c" name="question20">c) Natural Food Supplements<br>
    <input type="radio" value="d" name="question20">d) Disposable Diapers<br>
    </div>

    </form>

    <form>
    <div align="center">
    <input type="button" value="Grade Me!" name="B1" onClick="gradeit()"> <input type="button" value="Reset" name="B2" onClick="document.myquiz.reset()"></div>
    </form>
    </td>
    </tr>
    </table>
    <p id="footnote" align="center"><font face="arial" size="-1">Quiz script provided by<br>
    <a href="http://www.javascriptkit.com">JavaScriptKit.com</a></font></p>
    </body>
    </html>
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    <html>

    <head>
    <title>Instant Quiz Results</title>
    </head>

    <a href="http://www.downtimewitness.com/members/catfisherf" target="_blank"><img src="stamp.gif" width="133" height="26" border="0" align="top"
    hspace="5" vspace="5" alt="This Site Monitored by Downtime Witness"></a>

    <body bgcolor="#FFFFFF">

    <p align="center"><strong><font face="Times New Roman, Times, Serif">

    <script src="quizconfig.js">
    </script>

    <big>Instant Quiz Results</big></font></strong></p>
    <div align="center"><center>

    <table border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="100%"><form method="POST" name="result"><table border="0" width="100%" cellpadding="0" height="116">
    <tr>
    <td align="right" height="25" bgcolor="#008000"><strong><font face="Times" color="#ffffff"># of questions you got right&nbsp;</font></strong></td>
    <td height="25"><p><input type="text" name="p" size="24"></td>
    </tr>
    <tr>
    <td align="right" height="17" bgcolor="#008000"><strong><font face="Times" color="#ffffff">The questions you got wrong&nbsp;</font></strong></td>
    <td height="17"><p><textarea name="T2" rows="3" cols="24" wrap="virtual"></textarea></td>
    </tr>
    <tr>
    <td align="right" height="25" bgcolor="#008000"><strong><font face="Times" color="#ffffff">Grade in percentage&nbsp;</font></strong></td>
    <td height="25"><input type="text" name="q" size="8"></td>
    </tr>
    </table>
    </form>
    </td>
    </tr>
    </table>
    </center></div>

    <form method="POST"><div
    align="center"><center><p>

    <script>
    var wrong=0
    for (e=0;e<=2;e++)
    document.result[e].value=""

    var results=document.cookie.split(";")
    for (n=0;n<=results.length-1;n++){
    if (results[n].charAt(1)=='q')
    parse=n

    }

    var incorrect=results[parse].split("=")
    incorrect=incorrect[1].split("/")
    if (incorrect[incorrect.length-1]=='b')
    incorrect=""
    document.result[0].value=totalquestions-incorrect.length+" out of "+totalquestions
    document.result[2].value=(totalquestions-incorrect.length)/totalquestions*100+"%"
    for (temp=0;temp<incorrect.length;temp++)
    document.result[1].value+=incorrect[temp]+", "


    </script>

    <input type="button" value="Take the quiz again" name="B1"
    onClick="history.go(-1)"> <input type="button" value="View solution" name="B2"
    onClick="showsolution()"></p>
    </center></div>
    </form>

    <p align="center"><a href="catfisher.html" target="_blank"><img src="pics/homebutton.gif" width="110" height="46" border="0" align="top" hspace="5" vspace="5" alt="Return to Home Page"></A>

    <table>

    <tr>
    <td align="center"><img src="pics/poweredbybanner.gif" width="500" height="40" border="0" align="top" hspace="5" vspace="5" alt="Powered by Kiosk">

    <!--Kiosk Banner and Affiliate URL -->
    <a href="http://www.wwkiosk.com/g.o/catfisher" target="_blank"><img src="pics/kioskonestop.gif" width="468" height="68" border="0" align="top" hspace="5" vspace="5" alt="Kiosk Banner"></a>
    </td>
    </tr>

    <tr>
    <td><p align="center"><img src="/cgi-sys/Count.cgi?df=catfishe.dat|display=Counter|ft=6|md=6|frgb=178;34;34|dd=M"></p>
    </td>
    </tr>
    </table>

    <p id="footnote" align="center"><font face="arial" size="-1">Quiz script provided by<br>
    <a href="http://www.javascriptkit.com">JavaScriptKit.com</a></font></p>

    </body>
    </html>

  • #6
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You didn't happen to change the name of the results page:
    EG:window.location="results.htm"

    Particularly, changing .htm to .html

    .....Willy

  • #7
    New to the CF scene
    Join Date
    Jan 2004
    Location
    Welland, Ontario, Canada
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ha Ha. Funny thing happened. When I first got the script, (me being an accountant - I like everything organized) I did change the htm to html. But realizing the script wasn't going to work with the extension change, I fixed it. It is .htm for all scripts.


    index.html 11 k 644
    ** nutritionquiz.html 13 k 644
    popquiz.htm 11 k 644
    ** products.html 28 k 644
    quizscript.htm 3 k 644
    results.htm 3 k 644

    Here are how the files are sitting on my cpanel in public_html. The ** are the original pages, which are linked from index.html.
    The new quiz script pages are just sitting there, unlinked, because I can't get the results.htm to display

    Here is the URL for my site: http://catfisher.net

    Probably boring for you, but I am a nutrition person. K?

    catfisher

  • #8
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Where is: quizconfig.js

    I do not see it listed with the other files you listed:
    index.html 11 k 644
    ** nutritionquiz.html 13 k 644
    popquiz.htm 11 k 644
    ** products.html 28 k 644
    quizscript.htm 3 k 644
    results.htm 3 k 644

    The external .js file needs to be in the same folder as the
    Quiz and results.htm. If it is not, the paths need to be changed.

    .....Willy

  • #9
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I found it:
    http://catfisher.net/quizscript.htm

    Change that back to:
    quizconfig.js

    And try to be less organized.

    .....Willy

  • #10
    New to the CF scene
    Join Date
    Jan 2004
    Location
    Welland, Ontario, Canada
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Thank You

    I very much appreciate the time you spent fixing my problem.

    I didn't get a chance to try it out yet, but I will do it later. Dialup is sooooooooo bad.

    thanks again,
    catfisher


  •  

    Posting Permissions

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