»
Tiếng AnhTiếng PhápTiếng Việt

In - Trình trắc nghiệm - JavaScriptBank.com

Phiên bản đầy đủ: jsB@nk » Linh tinh » Trình trắc nghiệm
URL: https://www.javascriptbank.com/trivia-quiz-v-1.html

Trình trắc nghiệm © JavaScriptBank.comTrình trắc nghiệm yêu cầu ta trả lời câu hỏi trong thời gian qui định trước.

Phiên bản đầy đủ: jsB@nk » Linh tinh » Trình trắc nghiệm
URL: https://www.javascriptbank.com/trivia-quiz-v-1.html



CSS
<STYLE type=text/css>A {COLOR: blue; TEXT-DECORATION: none}A:active {COLOR: blue; TEXT-DECORATION: none}A:visited {COLOR: blue; TEXT-DECORATION: none}A:hover {COLOR: red; TEXT-DECORATION: none}</STYLE><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


JavaScript
<SCRIPT language=javascript>/*Trivia Quiz v 1.0by POZcomments, bug reports, suggestions will be welcome [email protected] be used freely as long as this credit is maintained.*//*Easy customizing instructions:1. Add as many questions as you like according to the structure of the existing demo questions.Make sure that every question is properly enveloped with <div id="questionX" style="display:none">...</div>where X is the number of the question (numbers must be sequential)2. Adjust the correctAnswers array to hold the letter of the correct answer for each question.3. Enjoy.*/// how many seconds available to answer each questionvar delay=10;// an array listing the correct answer for each question in order of appearancevar correctAnswers=new Array("c","d","b","d","c");// =====================================================// do not change script below this line// =====================================================var q_num=1;var timer;var layer;var clock=delay;var score=0;function show_question(){if (layer=eval("document.all.question"+q_num)){layer.style.display="inline";document.all.timeLeft.innerHTML=clock;hide_question();} else {document.all.timeLeft.innerHTML=0;document.all.quizScore.innerHTML="You have answered correctly "+score+" out of "+(q_num-1)+" questions.";document.all.quizScore.style.display="inline";}}function hide_question(){if (clock>0) {document.all.timeLeft.innerHTML=clock;clock--;timer=setTimeout("hide_question()",1000);} else {clearTimeout(timer);document.all.answerBoard.innerHTML="&nbsp;";clock=delay;layer.style.display="none";q_num++;show_question();}}function check_answer(answer){if (correctAnswers[q_num-1]==answer){score++;document.all.answerBoard.innerHTML="<i><b>Correct!</b></i>";} else {document.all.answerBoard.innerHTML="<i><b>Wrong!</b></i>";}clock=0;clearTimeout(timer);timer=setTimeout("hide_question()",1500);}window.onload=show_question;</SCRIPT><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<div style="text-align: left; width: 50%;">Time left: <SPAN id=timeLeft></SPAN>&nbsp; seconds<BR><DIV id=answerBoard>&nbsp;</DIV><BR><DIV id=question1 style="DISPLAY: none"><B>1. Who was the first man on the moon?</B><BR><A onclick="check_answer('a')" href="javascript:void(0)">a) Captain Kirk</A><BR><A onclick="check_answer('b')" href="javascript:void(0)">b) Tom Hanks</A><BR><A onclick="check_answer('c')" href="javascript:void(0)">c) Neil Armstrong</A><BR><A onclick="check_answer('d')" href="javascript:void(0)">d) Bugs Bunny</A><BR></DIV><DIV id=question2 style="DISPLAY: none"><B>2. What is the largest land mammal on earth?</B><BR><A onclick="check_answer('a')" href="javascript:void(0)">a) John Goodman</A><BR><A onclick="check_answer('b')" href="javascript:void(0)">b) Yo Mama</A><BR><A onclick="check_answer('c')" href="javascript:void(0)">c) Humpback Whale</A><BR><A onclick="check_answer('d')" href="javascript:void(0)">d) African Elephant</A><BR></DIV><DIV id=question3 style="DISPLAY: none"><B>3. Why?</B><BR><A onclick="check_answer('a')" href="javascript:void(0)">a) Because</A><BR><A onclick="check_answer('b')" href="javascript:void(0)">b) Why not?</A><BR><A onclick="check_answer('c')" href="javascript:void(0)">c) Who?</A><BR><A onclick="check_answer('d')" href="javascript:void(0)">d) He did it!</A><BR></DIV><DIV id=question4 style="DISPLAY: none"><B>4. Which of the following is the longest?</B><BR><A onclick="check_answer('a')" href="javascript:void(0)">a) one foot</A><BR><A onclick="check_answer('b')" href="javascript:void(0)">b) one kilometer</A><BR><A onclick="check_answer('c')" href="javascript:void(0)">c) one mile</A><BR><A onclick="check_answer('d')" href="javascript:void(0)">d) 753 light years</A><BR></DIV><DIV id=question5 style="DISPLAY: none"><B>5. Which of the following actors is least likely to ever win an oscar?</B><BR><A onclick="check_answer('a')" href="javascript:void(0)">a) Bruce Willis</A><BR><A onclick="check_answer('b')" href="javascript:void(0)">b) James Gandolfini</A><BR><A onclick="check_answer('c')" href="javascript:void(0)">c) Steven Seagal</A><BR><A onclick="check_answer('d')" href="javascript:void(0)">d) Mr. T</A><BR></DIV><DIV id=quizScore style="DISPLAY: none"></DIV></div><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->