Advertisement
asternauta

Kłiz taki fojny

May 16th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title></title>
  5. <meta charset="UTF-8"/>
  6. <link rel="stylesheet" href="test.css">
  7. </head>
  8. <body onload="Start()">
  9. <h1 id="naglowek">Test</h1>
  10. <div id="cos">
  11. <div>Pytanie nr <span id="nr_pytania"></span></div></br>
  12. <div id="tresc_pytania"></div>
  13. <div>
  14. <input type="radio" class="odp" name="odp" id="1"><span id="odp1">1</span></input></div>
  15. <input type="radio" class="odp" name="odp" id="2"><span id="odp2">2</span></input><br/>
  16. <input type="radio" class="odp" name="odp" id="3"><span id="odp3">3</span></input><br/>
  17. <input type="radio" class="odp" name="odp" id="4"><span id="odp4">4</span></input><br/>
  18. </div>
  19. <br/><br/>
  20. <button id="dalej" onclick="Akcja()">Dalej</button><br/><br/><br/>
  21. <!--<span id="wyn">Wynik: 0%</span>-->
  22. </div>
  23. <div id="podsum">
  24.  
  25. </div>
  26.  
  27. <script>
  28. const IlOdp = 4;
  29. var IlPytan = 13;
  30. var TPytania = [];
  31. var IlPrawidlowych = 0;
  32. var NrPytania;
  33. var i = 0;
  34. while (i < IlPytan)
  35. {
  36. TPytania[i] = [];
  37. ++i;
  38. }
  39.  
  40. var ElTrescPyt = document.getElementById("tresc_pytania");
  41. var ElNrPyt = document.getElementById("nr_pytania");
  42. var ElWynik = document.getElementById("wyn");
  43. </script>
  44. <script src="test_pytania.js"></script>
  45. <script>
  46.  
  47.  
  48. function WyswietlPytanie(nr)
  49. {
  50. ElNrPyt.innerHTML = (nr + 1) + " z " + IlPytan;
  51. ElTrescPyt.innerHTML = TPytania[nr][0];
  52. i = 1;
  53. while (i <= IlOdp)
  54. {
  55. document.getElementById("odp" + i).innerHTML = TPytania[nr][i];
  56. ++i;
  57. }
  58. }
  59.  
  60. function KasujZ()
  61. {
  62. i = 1;
  63. while (i <= IlOdp)
  64. {
  65. document.getElementById(i).checked = false;
  66. ++i;
  67. }
  68. }
  69.  
  70. function Akcja()
  71. {
  72. if (NrPytania < IlPytan - 1)
  73. {
  74. if (document.getElementById(TPytania[NrPytania][5]).checked)
  75. IlPrawidlowych++;
  76.  
  77. var wynik = Math.round((IlPrawidlowych/IlPytan)*100);
  78. ElWynik.innerHTML = "Wynik: " + wynik + "%";
  79. KasujZ();
  80. NrPytania++;
  81. WyswietlPytanie(NrPytania);
  82. }
  83. else
  84. WyswietlPodsumowanie();
  85. }
  86.  
  87. function Start()
  88. {
  89. KasujZ();
  90. NrPytania = 0;
  91. WyswietlPytanie(NrPytania);
  92. }
  93. </script>
  94. </body>
  95. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement