Full version: jsB@nk » Utility » Quiz » Take the Quiz
URL: https://www.javascriptbank.com/take-the-quiz.html
If you'd like to present your visitors with a JavaScript quiz, this script would be perfect. It administers and scores the test.
Full version: jsB@nk » Utility » Quiz » Take the Quiz
URL: https://www.javascriptbank.com/take-the-quiz.html
<SCRIPT language=javascript><!--//When adding questions make sure to add every variable to each function//Any questions email me!function checkform() {//How many were rightright = 0;//Get the answers from the from in the DOCUMENT from the form named MYQUIZ from the text area named A1 - A5, it gets its VALUE//Then change them to lower case.var ans1 = document.myquiz.a1.value;var ans1 = ans1.toLowerCase();var ans2 = document.myquiz.a2.value;var ans2 = ans2.toLowerCase();var ans3 = document.myquiz.a3.value;var ans3 = ans3.toLowerCase();var ans4 = document.myquiz.a4.value;var ans4 = ans4.toLowerCase();var ans5 = document.myquiz.a5.value;var ans5 = ans5.toLowerCase();//My question is Where can you get free JavaScripts?var que1 = "javascripts.com";//My question is Where can you get more free scripts?var que2 = "javascriptsource.com"; //My question is Where can you get all your programming questions answered?var que3 = "web developer forums";//My question is Where can you get a free guestbook?var que4 = "the guestbook.com";//My question is Where can you get a free counter for your site?var que5 = "the counter.com";//Tallys Scoreif (ans1 == que1) {right++document.myquiz.a1c.value = "+1";}else {document.myquiz.a1c.value = "X";}if (ans2 == que2) {right++document.myquiz.a2c.value = "+1";}else {document.myquiz.a2c.value = "X";}if (ans3 == que3) {right++document.myquiz.a3c.value = "+1";}else {document.myquiz.a3c.value = "X";}if (ans4 == que4) {right++document.myquiz.a4c.value = "+1";}else {document.myquiz.a4c.value = "X";}if (ans5 == que5) {right++document.myquiz.a5c.value = "+1";}else {document.myquiz.a5c.value = "X";}//Checks to see if anything was answeredif (ans1 == "" || ans2 =="" || ans3 =="" ||ans4 ==""||ans==""){document.myquiz.right.value = "You Answered Nothing!";}else {document.myquiz.right.value=right/5*100 + "% correct";}//Displays Wrong Answers}function check() {var ans1 = document.myquiz.a1.value;var ans1 = ans1.toLowerCase();var ans2 = document.myquiz.a2.value;var ans2 = ans2.toLowerCase();var ans3 = document.myquiz.a3.value;var ans3 = ans3.toLowerCase();var ans4 = document.myquiz.a4.value;var ans4 = ans4.toLowerCase();var ans5 = document.myquiz.a5.value;var ans5 = ans5.toLowerCase();//My question is Where can you get free JavaScripts?var que1 = "javascripts.com";//My question is Where can you get more free scripts?var que2 = "javascriptsource.com"; //My question is Where can you get all your programming questions answered?var que3 = "web developer forums";//My question is Where can you get a free guestbook?var que4 = "the guestbook.com";//My question is Where can you get a free counter for your site?var que5 = "the counter.com";//Checks to see if anything was answeredif (ans1 == "" && ans2 =="" && ans3 =="" && ans4 =="" && ans5==""){window.alert("You Answered Nothing!");}else {//correct answerif (ans1 == que1) {document.write("1) You Answered Correct. <br>");}//didnt answerelse {if (ans1 =="") {document.write("1) You didn't Answer this Question. <br>");}//wrong answerelse {document.write("1) You wrote <i>" + ans1 + "</i>. When you should've wrote " + que1 +".<br>");}}if (ans2 == que2) {document.write("2) You Answered Correct. <br>");}else {if (ans2 =="") {document.write("2) You didn't Answer this Question. <br>");}else {document.write("2) You wrote <i>" + ans2 + "</i>. When you should've wrote " + que3 +".<br>");}}if (ans3 ==que3) {document.write("3) You Answered Correct. <br>");}else {if (ans3 =="") {document.write("3) You didn't Answer this Question. <br>");}else {document.write("3) You wrote <i>" + ans3 + "</i>. When you should've wrote " + que3 +".<br>");}}if (ans4 == que4) {document.write("4) You Answered Correct. <br>");}else {if (ans4 =="") {document.write("4) You didn't Answer this Question. <br>");}else {document.write("4) You wrote <i>" + ans4 + "</i>. When you should've wrote " + que3 +".<br>");}}if (ans5 == que5) {document.write("5) You Answered Correct. <br>");}else {if (ans5 =="") {document.write("5) You didn't Answer this Question. <br>");}else {document.write("5) You wrote <i>" + ans5 + "</i>. When you should've wrote " + que5 +".<br>");}}}}//--></SCRIPT><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<TABLE height=205 width=487> <FORM name=myquiz> <TBODY> <TR> <TD width=461 colSpan=3> <P align=center><FONT face="Century Gothic" size=4><I>Take the Quiz On ________</I></FONT> </P></TD> <TR> <TD width=461 colSpan=3> <P align=center><FONT face="Century Gothic" color=#808080 size=2>Type your answer in the textbox directly next to the Question. </FONT></P></TD> <TR> <TD width=145 height=25><FONT face="Century Gothic">Where can you get free JavaScripts?:</FONT> <TD width=150 height=25><INPUT name=a1 size="20"> <TD width=172 height=25><INPUT style="BORDER-LEFT-COLOR: #ffffff; BORDER-BOTTOM-COLOR: #ffffff; COLOR: #808080; BORDER-TOP-STYLE: solid; BORDER-TOP-COLOR: #ffffff; FONT-FAMILY: Century Gothic; BORDER-RIGHT-STYLE: solid; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-COLOR: #ffffff; BORDER-BOTTOM-STYLE: solid" size=1 name=a1c> </TD> <TR> <TD width=145 height=25><FONT face="Century Gothic">Where can you get more free scripts?:</FONT> <TD width=150 height=25><INPUT name=a2 size="20"> <TD width=172 height=25><INPUT style="BORDER-LEFT-COLOR: #ffffff; BORDER-BOTTOM-COLOR: #ffffff; COLOR: #808080; BORDER-TOP-STYLE: solid; BORDER-TOP-COLOR: #ffffff; FONT-FAMILY: Century Gothic; BORDER-RIGHT-STYLE: solid; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-COLOR: #ffffff; BORDER-BOTTOM-STYLE: solid" size=1 name=a2c> </TD> <TR> <TD width=145 height=25><FONT face="Century Gothic">Where can you get all your programming questions answered?:</FONT> <TD width=150 height=25><INPUT name=a3 size="20"> <TD width=172 height=25><INPUT style="BORDER-LEFT-COLOR: #ffffff; BORDER-BOTTOM-COLOR: #ffffff; COLOR: #808080; BORDER-TOP-STYLE: solid; BORDER-TOP-COLOR: #ffffff; FONT-FAMILY: Century Gothic; BORDER-RIGHT-STYLE: solid; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-COLOR: #ffffff; BORDER-BOTTOM-STYLE: solid" size=1 name=a3c> </TD> <TR> <TD width=145 height=25><FONT face="Century Gothic">Where can you get a free guestbook?:</FONT> <TD width=150 height=25><INPUT name=a4 size="20"> <TD width=172 height=25><INPUT style="BORDER-LEFT-COLOR: #ffffff; BORDER-BOTTOM-COLOR: #ffffff; COLOR: #808080; BORDER-TOP-STYLE: solid; BORDER-TOP-COLOR: #ffffff; FONT-FAMILY: Century Gothic; BORDER-RIGHT-STYLE: solid; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-COLOR: #ffffff; BORDER-BOTTOM-STYLE: solid" size=1 name=a4c></TD> <TR> <TD width=145 height=25><FONT face="Century Gothic">Where can you get a free counter for your site?:</FONT> <TD width=150 height=25><INPUT name=a5 size="20"> <TD width=172 height=25><INPUT style="BORDER-LEFT-COLOR: #ffffff; BORDER-BOTTOM-COLOR: #ffffff; COLOR: #808080; BORDER-TOP-STYLE: solid; BORDER-TOP-COLOR: #ffffff; FONT-FAMILY: Century Gothic; BORDER-RIGHT-STYLE: solid; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-COLOR: #ffffff; BORDER-BOTTOM-STYLE: solid" size=1 name=a5c> </TD> <TR> <TD width=145 height=25><FONT face="Century Gothic">You Got:</FONT> <TD width=150 height=25 cellspan="2"><INPUT style="BORDER-LEFT-COLOR: #ffffff; BORDER-BOTTOM-COLOR: #ffffff; COLOR: #808080; BORDER-TOP-STYLE: solid; BORDER-TOP-COLOR: #ffffff; FONT-FAMILY: Century Gothic; BORDER-RIGHT-STYLE: solid; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-COLOR: #ffffff; BORDER-BOTTOM-STYLE: solid" size=24 value=Results name=right> </TD> <TR align=middle> <TD width=145 height=27><INPUT style="BORDER-LEFT-COLOR: #ffffff; BORDER-BOTTOM-COLOR: #ffffff; COLOR: #808080; BORDER-TOP-STYLE: solid; BORDER-TOP-COLOR: #ffffff; FONT-FAMILY: Century Gothic; BORDER-RIGHT-STYLE: solid; BORDER-LEFT-STYLE: solid; BACKGROUND-COLOR: #ffffff; BORDER-RIGHT-COLOR: #ffffff; BORDER-BOTTOM-STYLE: solid" onclick=checkform(); type=button value="Check Form"><BR> <TD width=150 height=27><INPUT style="BORDER-LEFT-COLOR: #ffffff; BORDER-BOTTOM-COLOR: #ffffff; COLOR: #808080; BORDER-TOP-STYLE: solid; BORDER-TOP-COLOR: #ffffff; FONT-FAMILY: Century Gothic; BORDER-RIGHT-STYLE: solid; BORDER-LEFT-STYLE: solid; BACKGROUND-COLOR: #ffffff; BORDER-RIGHT-COLOR: #ffffff; BORDER-BOTTOM-STYLE: solid" type=reset value=Reset> <!-- Tells User Which ones he had wrong! --> <TD width=172 height=27><INPUT style="BORDER-LEFT-COLOR: #ffffff; BORDER-BOTTOM-COLOR: #ffffff; COLOR: #808080; BORDER-TOP-STYLE: solid; BORDER-TOP-COLOR: #ffffff; FONT-FAMILY: Century Gothic; BORDER-RIGHT-STYLE: solid; BORDER-LEFT-STYLE: solid; BACKGROUND-COLOR: #ffffff; BORDER-RIGHT-COLOR: #ffffff; BORDER-BOTTOM-STYLE: solid" onclick=check(); type=button value="What Was Wrong?"> </TD></FORM></TR></TBODY></TABLE><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->