Results 1 to 3 of 3

Thread: Javascript help

  1. #1
    Join Date
    Oct 2009

    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.



    <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=''




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

    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

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

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

    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

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

    <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


    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


    <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"


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

  2. #2
    Join Date
    Oct 2003
    Andover, UK
    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
    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



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.12782 seconds
  • Memory Usage 2,862KB
  • Queries Executed 15 (?)
More Information
Template Usage (32):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (3)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates