Need Help For javascript assignment

Discussion in 'JavaScript' started by RuffusJones, Feb 2, 2008.

  1. #1
    I need to make a movie quiz with 3 possible outcomes. when i try loading it, nothing happens, the prompts stopped working when i added the variables at the top. Heres what i have so far.


    <script type="text/javascript">
    var response1 = "", response2 ="", response3 ="";
    var comedy = 5;
    var horror = 5;
    var action = 5;

    function processScore() {
    var score = 0 // keeps track of score


    response1 = prompt("What is your favorite genre or film?", "Enter here")
    if (prompt == comedy){
    score = score + 1}


    response2 = prompt("What is your favorite movie of all time?", "Enter here")
    if (prompt == horror){
    score = score + 1}


    response3 = prompt("Who is your favotire Actor?", "Anyone but Keanu Reeves")
    if (prompt == action){
    score = score + 1}

    </script>
    <form id="answersForm" name ="answersForm">
    <input type="button" value="Grade the Quiz!"
    onclick="processScore()">
    <input type ="text" name ="scoreBox"size="1">
    </form>
    </body>
     
    RuffusJones, Feb 2, 2008 IP
  2. blueparukia

    blueparukia Well-Known Member

    Messages:
    1,564
    Likes Received:
    71
    Best Answers:
    7
    Trophy Points:
    160
    #2
    Separate them to 3 vars.

    As for the rest...wtf?.


    
    response3 = prompt("Who is your favotire Actor?", "Anyone but Keanu Reeves")
    if (prompt == action){
    score = score + 1}
    Code (markup):
    .

    To me that makes little sense. If action = 5, then that means you must enter 5 into te prompt?.

    That code doesn't look like it will do anything at all. Can you please tell me what you want to happen when you hit the button?
     
    blueparukia, Feb 2, 2008 IP
  3. RuffusJones

    RuffusJones Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Your right my code is pretty iced out on meth. Luckily i figured out the problem on my own...sort of but thanx for replying .:)
     
    RuffusJones, Feb 3, 2008 IP