www.webdeveloper.com
Results 1 to 3 of 3

Thread: Javascript help

  1. #1
    Join Date
    Oct 2009
    Posts
    2

    Javascript help

    Write a program to allow users to take a 5-question quiz and receive their score when finished.

    Minimum Requirements:

    1. Draw a sketch of what your web page will look like. This must be approved before starting the code.

    2. Create a variable to keep track of the total score. Give it a descriptive name and an appropriate starting value.

    3. Create variables to keep track of the points received for each question. Give them descriptive names and appropriate starting values.

    4. Create variables to keep track of the message to display for each question. Give them descriptive names and appropriate starting values.

    5. Create 5 multiple-choice questions related to a content-specific theme (English, Math, Science, or Social Studies).

    6. Offer four answer choices for each question.

    7. Create a button to start over (clear the form and reset variables to their initial values.)

    8. Create a button to grade the quiz.

    9. Create a blank textbox after each set of answers to display the result of the user’s answer choice. Do NOT display anything in these boxes until after the user clicks the ‘grade quiz’ button.

    10. When the user chooses an answer (clicks a radio button), have the computer store the points earned for that question in the appropriate variable. Also store the result (correct or incorrect) for that question in the appropriate variable. Questions 1 and 2 are worth 1 point each. Questions 3 and 4 are worth 2 points each. Question 5 is worth 5 points. An incorrect answer receives 0 points.

    11. Create a textbox at the bottom of the quiz to display the final quiz results.

    12. When the user clicks the ‘grade quiz’ button:
    A. Display the correct answers for each question in the appropriate text boxes.
    B. Total the points received for the quiz and display the result in the textbox at the bottom of the quiz.
    C. Show the total points received as well as the percentage, rounded to the nearest hundredths place (i.e. .967865 would be displayed as 96.79%)

    13. Include instructions for the user on how to use your quiz.

    Possible enhancements: custom buttons; extra questions; only let the user answer once; excellent formatting of questions/answers.

    THIS IS WHAT I HAVE DONE: CAN SOMEONE HELP ME DO THE REST

    <HEAD>



    <script language="JavaScript">
    var q1=0 //hold the answer for q1
    var q2=1
    var q3=2
    var q4=3


    var mes1='' //message for the answer
    var mes2=''
    var mes3=''
    var mes4=''


    </script>

    </HEAD>


    <BODY>

    <h3>Chemistry quiz</h3>

    <form name="quiz">
    1. What is the formula for Density?
    <ul style="margin-top: 1pt">
    <li><input type="radio" name="q1" value="D=M/V" onClick="q1=0;mes1='Yes that is the

    correct answer!'"> D=M/V </li>
    <li><input type="radio" name="q2" value="D=V/M">D=V/M</li>
    <li><input type="radio" name="q3" value="D=V*M">D=V*M</li>
    <li><input type="radio" name="q4" value="D=V-M">D=V-M</li>
    <li><input type=text name=textmessagebox size=60 maxlength=60>
    </ul>

    2. What does a chemical change do?
    <ul style="margin-top: 1pt">
    <li><input type="radio" name="q2" value="does not produce a new substance">does not

    produce a new substance</li>
    <li><input type="radio" name="q2" value="produces a new substance">produces a new

    substance</li>
    <li><input type="radio" name="q2" value="destroys the chemical">destroys the

    chemical</li>
    <li><input type="radio" name="q2" value="duplicates the chemical">duplicates the

    chemical</li>
    </ul>
    3. what are the signs of a chemical change?
    <ul style="margin-top: 1pt">
    <li><input type="radio" name="q3" value="formation of a solid">formation of a solid</li>
    <li><input type="radio" name="q3" value="does not change color">does not change

    color</li>
    <li><input type="radio" name="q3" value="does not produce gas">does not produce gas</li>
    <li><input type="radio" name="q3" value="changes in mass">changes in mass</li>
    </ul>
    4. What is an atom?
    <ul style="margin-top: 1pt">
    <li><input type="radio" name="q4" value="the smallest unit of an element">the smallest

    unit of an element</li>
    <li><input type="radio" name="q4" value="smallest unit of a compund">smallest unit of a

    compund</li>
    <li><input type="radio" name="q4" value="a mixture">a mixture</li>
    <li><input type="radio" name="q4" value="cannot be a pure substance">cannot be a pure

    substance</li>
    </ul>

    5. What is an element?
    <ul style="margin-top: 1pt">
    <li><input type="radio" name="q5" value="cannot be broken down or separated>cannot be

    broken down or separated</li>
    <li><input type="radio" name="q5" value="can be separated">can be separated </li>
    <li><input type="radio" name="q5" value="does not have the same atomic number">does not

    have the same atomic number</li>
    <li><input type="radio" name="q5" value="cannot be broken down">cannot be broken

    down</li>


    <input type="button" value="Get score" onClick="getScore(this.form)">
    <input type="reset" value="Clear answers">
    <p> Score = <strong><input class="bgclr" type="text" size="5" name="percentage"

    disabled></strong><br><br>
    </textarea>
    </form>


    <p><center>
    <font face="arial, helvetica" size"-2">Hope you did well!<br>
    By: Me</a></font>
    </center><p>

  2. #2
    Join Date
    Oct 2003
    Location
    Andover, UK
    Posts
    945
    Man, you didn't seriously just copy and paste your entire assignment and hope someone would do it for you, without so much as a "hi" or "thanks in advance", did you?

    Post some specific question, show us you're actually meeting us halfway and we'll help out.

  3. #3
    Join Date
    Oct 2009
    Posts
    2
    oh sorry man i was at school and time was running out so i did it in a hurry anyways well i just posted the instructions so u guys can see what it is supposed 2 be like btw i did do most it.... so i am not asking you to do the whole thing... i just can't get the variables to work and don't know how to get the textbox to score what the user clicks and in the end when the user clicks grade quiz every textbox after each question says either yes that was right or no that was not right it was c.... so thats what i cant get and in the textbox under grade quiz it should say you have scored 5 out of 11 points and that is a 45.45% thats what i need and these things i just can't get

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles