SHARE
TWEET

Untitled

Brad-Hillier Oct 22nd, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. <!---Answers--->
  3. var answer1="4";
  4. var answer2="4";
  5. var answer3="6";
  6. var answer4="5";
  7.  
  8. <!---Score Variable--->
  9. var score=0;
  10.  
  11. <!---show X--->
  12. function showWrong1(){
  13. var wrong1=document.getElementById("wrong1");
  14. wrong1.style.visibility="visible";}
  15. function showWrong2(){
  16. var wrong2=document.getElementById("wrong2");
  17. wrong2.style.visibility="visible";}
  18. function showWrong3(){
  19. var wrong3=document.getElementById("wrong3");
  20. wrong3.style.visibility="visible";}
  21. function showWrong4(){
  22. var wrong4=document.getElementById("wrong4");
  23. wrong4.style.visibility="visible";}
  24.  
  25. <!---Hide X--->
  26. function hideWrong1(){
  27. var wrong1=document.getElementById("wrong1");
  28. wrong1.style.visibility="hidden";}
  29. function hideWrong2(){
  30. var wrong2=document.getElementById("wrong2");
  31. wrong2.style.visibility="hidden";}
  32. function hideWrong3(){
  33. var wrong3=document.getElementById("wrong3");
  34. wrong3.style.visibility="hidden";}
  35. function hideWrong4(){
  36. var wrong4=document.getElementById("wrong4");
  37. wrong4.style.visibility="hidden";}
  38.  
  39. <!---Show Checkmark--->
  40. function showCheck1(){
  41. var check1=document.getElementById("check1");
  42. check1.style.visibility="visible";}
  43. function showCheck2(){
  44. var check2=document.getElementById("check2");
  45. check2.style.visibility="visible";}
  46. function showCheck3(){
  47. var check3=document.getElementById("check3");
  48. check3.style.visibility="visible";}
  49. function showCheck4(){
  50. var check4=document.getElementById("check4");
  51. check4.style.visibility="visible";}
  52.  
  53. <!---Hide Checkmark--->
  54. function hideCheck1(){
  55. var check1=document.getElementById("check1");
  56. check1.style.visibility="hidden";}
  57. function hideCheck2(){
  58. var check2=document.getElementById("check2");
  59. check2.style.visibility="hidden";}
  60. function hideCheck3(){
  61. var check3=document.getElementById("check3");
  62. check3.style.visibility="hidden";}
  63. function hideCheck4(){
  64. var check4=document.getElementById("check4");
  65. check4.style.visibility="hidden";}
  66.  
  67. <!---Hide All--->
  68. function hideAll(){
  69. hideCheck1();
  70. hideCheck2();
  71. hideCheck3();
  72. hideCheck4();
  73. hideWrong1();
  74. hideWrong2();
  75. hideWrong3();
  76. hideWrong4();}
  77.  
  78.  
  79. <!---Incomplete Function--->
  80. function incomplete(){
  81. var incomplete=document.getElementById("incomplete");
  82. incomplete.style.visibility="visible";
  83. setTimeout(hideIncomplete,3000);}
  84.  
  85. function hideIncomplete(){
  86. var incomplete=document.getElementById("incomplete");
  87. incomplete.style.visibility="hidden";}
  88.  
  89. <!---Audio--->
  90.  var check1 = new Audio('Media/CheckmarkSFX.mp3');
  91.  var check2 = new Audio('Media/CheckmarkSFX.mp3');
  92.  var check3 = new Audio('Media/CheckmarkSFX.mp3');
  93.  var check4 = new Audio('Media/CheckmarkSFX.mp3');
  94.  var RedCross1 = new Audio('Media/RedCrossSFX.mp3');
  95.  var RedCross2 = new Audio('Media/RedCrossSFX.mp3');
  96.  var RedCross3 = new Audio('Media/RedCrossSFX.mp3');
  97.  var RedCross4 = new Audio('Media/RedCrossSFX.mp3');
  98.  
  99.  <!---Form Complete Verification--->
  100.  
  101.  
  102.  
  103. <!---Submit button Script (Compare input Answers to correct Answer and display appropriate image)--->
  104. function submit(){
  105.   score=0;
  106.   hideAll();
  107.   question1();}
  108.  
  109. function question1(){
  110.   var input1=document.getElementById("input1").value;
  111.   var mark1=input1===answer1;
  112.   if(mark1){
  113.   check1.play();
  114.   score++;
  115.   showCheck1()
  116.   hideWrong1()}else{
  117.   RedCross1.play();
  118.   hideCheck1()
  119.   showWrong1()}
  120.   document.getElementById("score").innerHTML="Score: "+score+"/4";
  121.   setTimeout(question2,1000);}
  122.  
  123. <!---Question 2--->
  124. function question2(){
  125.   var input2=document.getElementById("input2").value;
  126.   var mark2=input2===answer2;
  127.   if(mark2){
  128.   check2.play();
  129.   score++;
  130.   showCheck2()
  131.   hideWrong2()}else{
  132.   RedCross2.play();
  133.   hideCheck2()
  134.   showWrong2()}
  135.   document.getElementById("score").innerHTML="Score: "+score+"/4";
  136.   setTimeout(question3,1000);}
  137.  
  138. <!---Question 3--->
  139. function question3(){
  140.   var input3=document.getElementById("input3").value;
  141.   var mark3=input3===answer3;
  142.   if(mark3){
  143.   check3.play();
  144.   score++;
  145.   showCheck3()
  146.   hideWrong3()}else{
  147.   RedCross3.play();
  148.   hideCheck3()
  149.   showWrong3()}
  150.   document.getElementById("score").innerHTML="Score: "+score+"/4";
  151.   setTimeout(question4,1000);}
  152.  
  153. <!---Question 4--->
  154. function question4(){
  155.   var input4=document.getElementById("input4").value;
  156.   var mark4=input4===answer4;
  157.   if(mark4){
  158.   check4.play();
  159.   score++;
  160.   showCheck4()
  161.   hideWrong4()}else{
  162.   RedCross4.play();
  163.   hideCheck4()
  164.   showWrong4()}
  165.   document.getElementById("score").innerHTML="Score: "+score+"/4";
  166.   }}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top