• Welcome to The Cave of Dragonflies forums, where the smallest bugs live alongside the strongest dragons.

    Guests are not able to post messages or even read certain areas of the forums. Now, that's boring, don't you think? Registration, on the other hand, is simple, completely free of charge, and does not require you to give out any personal information at all. As soon as you register, you can take part in some of the happy fun things at the forums such as posting messages, voting in polls, sending private messages to people and being told that this is where we drink tea and eat cod.

    Of course I'm not forcing you to do anything if you don't want to, but seriously, what have you got to lose? Five seconds of your life?

Quiz Problems

IndigoClaudia

The Fool
Pronoun
Ask; Try She/Her
So i made a quiz (What mythical pokémon are you) and the quiz works as you think it would, but then it doesn't show the results when you submit the stuff.

So here's the code. I got all of it from butterfree's free quiz script.

HTML:
<form name="quizform">
<h4>What Mythical pokémon do you think you will get?</h4>
<ul>
<li><label><input type="radio" name="q1" value="Mew" checked> Mew</label></li>
<li><label><input type="radio" name="q1" value="Celebi"> Celebi </label></li>
<li><label><input type="radio" name="q1" value="Jirachi"> Jirachi </label></li>
<li><label><input type="radio" name="q1" value="Shaymin"> Shaymin</label></li>
<li><label><input type="radio" name="q1" value="Phione"> Phione or Manaphy</label></li>
<li><label><input type="radio" name="q1" value="Victini"> Victini</label></li>
<li><label><input type="radio" name="q1" value="Darkrai"> Darkrai</label></li>
<li><label><input type="radio" name="q1" value="Keldeo"> Keldeo </label></li>
<li><label><input type="radio" name="q1" value="Melloetta"> Melloetta</label></li>
<li><label><input type="radio" name="q1" value="Diancie"> Diancie </label></li>
<li><label><input type="radio" name="q1" value="Hoopa"> Hoopa</label></li>
<li><label><input type="radio" name="q1" value="Magearna"> Magearna</label></li>
<li><label><input type="radio" name="q1" value="Marshadow"> Marshadow</label></li>
<li><label><input type="radio" name="q1" value="Zeraora"> Zeraoara</label></li>
<li><label><input type="radio" name="q1" value="Meltan"> Melmetal</label></li>
<li><label><input type="radio" name="q1" value="Zarude"> Zarude</label></li>

</ul>

<h4>Favorite food?</h4>
<ul>
<li><label><input type="radio" name="q2" value="Zeraora" checked>Something SPICY</label></li>
<li><label><input type="radio" name="q2" value="Jirachi">Something healthy</label></li>
<li><label><input type="radio" name="q2" value="Magearna">Something Exotic</label></li>
<li><label><input type="radio" name="q2" value="Darkrai"> Eating is for chumps!</label></li>
<li><label><input type="radio" name="q2" value="Shaymin">Vegetables veggggggggiiiieeesss man.</label></li>
<li><label><input type="radio" name="q2" value="Celebi"> Salad </label></li>
<li><label><input type="radio" name="q2" value="Victini">Fruits</label></li>
<li><label><input type="radio" name="q2" value="Mew"> Cake</label></li>
<li><label><input type="radio" name="q2" value="Melloetta">Chocoalte</label></li>
<li><label><input type="radio" name="q2" value="Diancie">Sweets </label></li>
<li><label><input type="radio" name="q2" value="Keldeo"> Poutine </label></li>
<li><label><input type="radio" name="q2" value="Hoopa">Mac N Cheese</label></li>
<li><label><input type="radio" name="q2" value="Meltan">Burgers</label></li>
<li><label><input type="radio" name="q2" value="Zarude">Meat</label></li>
<li><label><input type="radio" name="q2" value="Phione">Soup</label></li>
<li><label><input type="radio" name="q2" value="Marshadow">I have no idea</label></li>

</ul>

<h4>Favorite Colors?</h4>
<ul>
<li><label><input type="radio" name="q3" value="Zeraora" checked>Yellow</label></li>
<li><label><input type="radio" name="q3" value="Jirachi">Gold</label></li>
<li><label><input type="radio" name="q3" value="Magearna">Silver</label></li>
<li><label><input type="radio" name="q3" value="Darkrai"> Black... like my soul</label></li>
<li><label><input type="radio" name="q3" value="Shaymin">White</label></li>
<li><label><input type="radio" name="q3" value="Celebi"> Dark Green</label></li>
<li><label><input type="radio" name="q3" value="Victini">Red</label></li>
<li><label><input type="radio" name="q3" value="Mew">I like all the colors</label></li>
<li><label><input type="radio" name="q3" value="Melloetta">Brown</label></li>
<li><label><input type="radio" name="q3" value="Diancie">Hot pink </label></li>
<li><label><input type="radio" name="q3" value="Keldeo">Greenish-Blue</label></li>
<li><label><input type="radio" name="q3" value="Hoopa">Purple</label></li>
<li><label><input type="radio" name="q3" value="Meltan">Burgers</label></li>
<li><label><input type="radio" name="q3" value="Zarude">Colors are stupid</label></li>
<li><label><input type="radio" name="q3" value="Phione">Blue</label></li>
<li><label><input type="radio" name="q3" value="Marshadow">I mean... gray maybe?</label></li>
</ul>

<h4>What is your personality?</h4
<ul>
<li><label><input type="radio" name="q4" value="Phione" checked>Laid-Back</label></li>
<li><label><input type="radio" name="q4" value="Keldeo">Trend-setter</label></li>
<li><label><input type="radio" name="q4" value="Marshadow">Shy and Introverted</label></li>
<li><label><input type="radio" name="q4" value="Mew">Optimistic</label></li>
<li><label><input type="radio" name="q4" value="Meltan">Gentle and Loyal</label></li>
<li><label><input type="radio" name="q4" value="Darkrai"> EDGY</label></li>
<li><label><input type="radio" name="q4" value="Celebi">Loveable</label></li>
<li><label><input type="radio" name="q4" value="Hoopa">A Prankster/Funny</label></li>
<li><label><input type="radio" name="q4" value="Diancie">Elegant</label></li>
<li><label><input type="radio" name="q4" value="Zeraora">A bit reckless...</label></li>
<li><label><input type="radio" name="q4" value="Victini">Energetic</label></li>
<li><label><input type="radio" name="q4" value="Jirachi">Tired</label></li>
<li><label><input type="radio" name="q4" value="Magearna">Thoughtful</label></li>
<li><label><input type="radio" name="q4" value="Zarude">A bit grumpy</label></li>
<li><label><input type="radio" name="q4" value="Melloetta">I'm one of the nerdy theater kids</label></li>
<li><label><input type="radio" name="q4" value="Shaymin">Jock</label></li>
</ul>

<h4>One last question, What do you do on a typical weekend.</h4>
<ul>
<li><label><input type="radio" name="q5" value="Phione" checked>Just Kinda chill</label></li>
<li><label><input type="radio" name="q5" value="Keldeo">I do all sorts of stuff. I play video games i hang with friends i go...</label></li>
<li><label><input type="radio" name="q5" value="Marshadow">Stay home and read</label></li>
<li><label><input type="radio" name="q5" value="Mew">Meen with friends</label></li>
<li><label><input type="radio" name="q5" value="Meltan">Help people out</label></li>
<li><label><input type="radio" name="q5" value="Darkrai">ACT EDGY</label></li>
<li><label><input type="radio" name="q5" value="Celebi">It's a secret</label></li>
<li><label><input type="radio" name="q5" value="Hoopa">Prank People</label></li>
<li><label><input type="radio" name="q5" value="Diancie">It depends</label></li>
<li><label><input type="radio" name="q5" value="Zeraora">Go outside and do something active</label></li>
<li><label><input type="radio" name="q5" value="Victini">Annoy the people!!!</label></li>
<li><label><input type="radio" name="q5" value="Jirachi">Sleep in</label></li>
<li><label><input type="radio" name="q5" value="Magearna">Work on homework/work</label></li>
<li><label><input type="radio" name="q5" value="Zarude">Weekends are for chumps</label></li>
<li><label><input type="radio" name="q5" value="Melloetta">Sing/Perform/Act (If i can)</label></li>
<li><label><input type="radio" name="q5" value="Shaymin">...My weekends are very confusing.</label></li>
</ul>


<p><button type="submit">Submit your answers</button></p>

<div id="result_div" style="display:none;">
<img id="result_image" alt="">
<p id="result_text"></p>
<p>BBCode:<br>
<textarea rows="3" cols="30" id="result_bbcode"></textarea></p>

<p>HTML:<br>
<textarea rows="3" cols="30" id="result_html"></textarea></p>
</div>
</form>
<script type="text/javascript">
(function() {
    /*************************************************************************
    This should be the full address to your quiz, in order for the result
    codes to link to it.

    *************************************************************************/
    var QUIZ_URL = "http://IndigoCorner.Neocities.org/quizzes.html";

    /*************************************************************************
    This should be the full address to whatever folder on your website
    directly contains your result images, ending in a forward slash.

    *************************************************************************/
    var RESULTS_FOLDER_URL = "http://IndigoCorner.Neocities.org/mythresults/";

    /*************************************************************************
    Below, enter the possible final results for your quiz.

    The format should be relatively self-explanatory, but here's a rundown
    anyway:

    Where it says "value1", "value2", etc., enter the name you will put into
    the VALUE attribute of that result's answers. For example, if Alakazam is
    one of the possible results in your quiz, you could enter "alakazam". This
    value will not be displayed to your visitor, so it does not need to be
    capitalized or punctuated. It should not contain quotation marks,
    ampersands or backslashes (", & or \).

    Where it says "Result 1", "Result 2", etc., enter the full name of the
    result, such as "Alakazam". Where it says "result_1.jpg", "result_2.jpg",
    etc., enter the filename of the image the user should be presented with if
    they get that result. Where it says "Text for the first result", "Text for
    the second result", etc., enter the text the user should be presented with
    if they get that result. (If you do not want them to get any text with
    their result, you can erase those lines altogether.) Remember to enclose
    these values in quotes.

    It is also possible to leave out the name, image and text and instead add
    a link property, like so:

    RESULTS["alakazam"] = {
        link: "/quiz/alakazam.html"
    };

    If you do this, then the user will be redirected to the link for their
    result when they finish the quiz. The link, like a regular HTML link, can
    be a full URL or an absolute or relative path on your server.

    You can have as many possible results as you like - four is just the
    default.

    If you want to include "intermediate" results - special results for
    ties between two or more regular results - those should be entered with
    an ampersand between the tied values:

    RESULTS["value1&value2"] = {
        name: "Result 1/2 tie",
        image: "result_1_2.jpg",
        text: "Text for a tie between the first and second result"
    };

    This is completely optional; if you don't include an intermediate result,
    then the result listed first here will simply take precedence. The order
    of the values in a tiebreaker result should also match the order given
    here (that is, "value1&value2" works when value1 comes before value2,
    while "value2&value1" would not).

    *************************************************************************/

    var RESULTS = {};

    RESULTS["Mew"] = {
        name: "Mew",
        image: "1.png",
        text: "You got... Mew :D"
    };

    RESULTS["Celebi"] = {
        name: "Result 2",
        image: "2.png",
        text: "You got Celebi"
    };

    RESULTS["Jirachi"] = {
        name: "Result 3",
        image: "3.png",
        text: "Wake up sleepyhead, you got Jirachi"
    };

    RESULTS["Shaymin"] = {
        name: "Result 4",
        image: "placeholder.png",
        text: "Wheeeeeee you got shaymin"
        
     RESULTS["Phione"] = {
        name: "Result 4",
        image: "placeholder.png",
        text: "You got Phione and Manaphy! Yay"
    };
    RESULTS["Victini"] = {
        name: "Result 4",
        image: "placeholder.png",
        text: "Hello my good buddies and make your way to victory! Because you are victini!"
 
    RESULTS["Darkrai"] = {
        name: "Result 4",
        image: "placeholder.png",
        text: "I aM WoRrIeD yOu WiLl CuT mE wItH aLl ThAt EdGe YoU hAvE. yOu aRe DaRkRaI!"
        
    RESULTS["Melloetta"] = {
        name: "Result 4",
        image: "placeholder.png",
        text: "Let me sing out your result: Melloetta"
        
    RESULTS["Keldeo"] = {
        name: "Keldeo",
        image: "placeholder.png",
        text: "(Keldeo is the coolest one, but don't tell anyone) you got Keldeo"
        
        
    RESULTS["Diancie"] = {
        name: "Result 4",
        image: "placeholder.png",
        text: "Sparkle like a diamond for you are Diancie!"
        
    RESULTS["Hoopa"] = {
        name: "Result 4",
        image: "placeholder.png",
        text: "Ahh... you are hoopa"
        
    RESULTS["Magearna"] = {
        name: "Result 4",
        image: "placeholder.png",
        text: "You got... Magearna. Now you should be happy because you finished the quiz."
        
    RESULTS["Marshadow"] = {
        name: "Result 4",
        image: "placeholder.png",
        text: "There you are! You got marshadow!"
        
    RESULTS["Zeraora"] = {
        name: "Result 4",
        image: "placeholder.png",
        text: "WWWWWWWHHHHHHEEEEEEEEEEEEEEEE HEEEEEEEEEEEEEEEEEE"
        
    RESULTS["Melmetal"] = {
        name: "Result 4",
        image: "placeholder.png",
        text: "You got melmetal"
        
    RESULTS["Zarude"] = {
        name: "Result 4",
        image: "placeholder.png",
        text: "Oh no... you haven't even been released yet... and you got Zarude!"
        
        

    /*************************************************************************
    If for some reason you need to give your form a different name attribute
    than "quizform", enter it here. Otherwise, leave this alone.

    *************************************************************************/
    var FORM_NAME = 'quizform';

    /*************************************************************************
    DO NOT EDIT ANYTHING BELOW THIS POINT

    *************************************************************************/

    var form = document.forms[FORM_NAME];
    var form_elements = document.forms[FORM_NAME].elements;
    var form_element;
    var result_div = document.getElementById("result_div");
    var result_image = document.getElementById("result_image");
    var result_text = document.getElementById("result_text");
    var result_bbcode = document.getElementById("result_bbcode");
    var result_html = document.getElementById("result_html");

    // Validate the quiz form to prevent common issues
    for (var i = 0; i < form_elements.length; i++) {
        form_element = form_elements[i];
        if (form_element.type === "radio") {
            if (form_element.value.indexOf('&') !== -1) {
                alert("Your quiz form has an answer with an ampersand in the value (" + form_element.value + "). This will cause problems. Please change this value.");
            }
            else if (!(form_element.value in RESULTS)) {
                alert("Your quiz form has an answer with the value " + form_element.value + " but there is no result corresponding to this value. You have probably made a typo somewhere.");
            }
        }
    }

    form.onsubmit = function() {
        var answers = {};
        var results = [];
        var joined_results;
        var result;
        var form_element;

        for (var value in RESULTS) {
            if (value.indexOf('&') === -1) {
                // Not a joint result
                answers[value] = 0;
            }
        }

        for (var i = 0; i < form_elements.length; i++) {
            form_element = form_elements[i];
            if ((form_element.type === "radio" || form_element.type === "checkbox") && form_element.checked) {
                answers[form_element.value]++;
            }
        }

        for (var value in answers) {
            if (results.length === 0 || answers[value] > answers[results[0]]) {
                results = [value];
            }
            else if (answers[value] === answers[results[0]]) {
                results.push(value);
            }
        }

        while (results.length > 0) {
            joined_results = results.join('&');
            if (joined_results in RESULTS) {
                result = RESULTS[joined_results];
                break;
            }
            else {
                // No joint result - remove the last element and see if
                // there's a result for that.
                results.pop();
            }
        }

        if (result.link) {
            window.location = result.link;
            return false;
        }

        if (result_image) {
            result_image.src = RESULTS_FOLDER_URL + result.image;
            result_image.setAttribute('alt', result.name);
            if (result.text) result_image.title = result.text;
        }
        if (result_text && result.text) {
            result_text.innerHTML = result.text;
        }
        if (result_bbcode) {
            result_bbcode.innerHTML = '[url=' + QUIZ_URL + '][img]' + RESULTS_FOLDER_URL + result.image + '[/img][/url]';
        }
        if (result_html) {
            result_html.innerHTML = '<a href="' + QUIZ_URL + '"><img src="' + RESULTS_FOLDER_URL + result.image + '" alt="' + result.name + '" title="' + result.text + '"></a>';
        }
        result_div.style.display = 'block';
        return false;
    };
})();

/*************************************************************************
Free quiz script from The Cave of Dragonflies:
http://www.dragonflycave.com/free-quiz-scripts
*************************************************************************/

If you see what the problem is or I am forgetting something important, please tell me.
 

kyeugh

onion witch
Pronoun
she/her
most of your result fields aren't being closed. for example, you have a series of blocks of code like this:
JavaScript:
RESULTS["Zarude"] = {
        name: "Result 4",
        image: "placeholder.png",
        text: "Oh no... you haven't even been released yet... and you got Zarude!"
see that curly bracket { on the first line? it needs to be matched with a closing bracket, like so (see the last line):
JavaScript:
RESULTS["Zarude"] = {
        name: "Result 4",
        image: "placeholder.png",
        text: "Oh no... you haven't even been released yet... and you got Zarude!"
};
and so on for all of your results. some of them like mew/celebi/jirachi are fine already, but most of them need to be fixed.
 

IndigoClaudia

The Fool
Pronoun
Ask; Try She/Her
Ahh thanks. I'll see if it works.
EDIT: It works. Thanks so much!
EDIT: if you look at my signature there is a one in three chance it will show my quiz result.
 
Last edited:
Top