Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. <html>
  2. <head>
  3. <style>
  4. .przycisk{
  5. width: 100px;
  6. height:100px;
  7. background-color:black;
  8. color:red;
  9. font-size:70px;
  10. }
  11. </style>
  12.  
  13. <script>
  14.  
  15. var krzyzyk=false;
  16.  
  17. function wstaw(nr)
  18. {
  19. if(document.getElementById(nr).value=="")
  20. {
  21. if (krzyzyk==false)
  22. {
  23. document.getElementById(nr).value='X';
  24. krzyzyk=true;
  25.  
  26.  
  27. }
  28.  
  29. else
  30. {
  31. document.getElementById(nr).value='O';
  32. krzyzyk=false;
  33. }
  34.  
  35. }
  36. }
  37.  
  38. function sprawdz(a,b,c,znak)
  39. {
  40. let x,y,z,w;
  41.  
  42. x=document.getElementById(a).value;
  43. y=document.getElementById(b).value;
  44. z=document.getElementById(c).value;
  45.  
  46. if((x==y)&&(y==z)&&(z==znak))
  47. return true;
  48. else
  49. return false;
  50. }
  51.  
  52. function sprawdzenie()
  53. {
  54. if (sprawdz('button1','button2','button3','X')) alert ("Wygrał X");
  55. if (sprawdz('button4','button5','button6','X')) alert ("Wygrał X");
  56.  
  57.  
  58. }
  59. </script>
  60. </head>
  61. <body>
  62. <div>
  63. <input class="przycisk" type="button" id="button1" onclick="wstaw('button1')">
  64. <input class="przycisk" type="button" id="button2" onclick="wstaw('button2')">
  65. <input class="przycisk" type="button" id="button3" onclick="wstaw('button3')"> <br>
  66. <input class="przycisk" type="button" id="button4" onclick="wstaw('button4')">
  67. <input class="przycisk" type="button" id="button5" onclick="wstaw('button5')">
  68. <input class="przycisk" type="button" id="button6" onclick="wstaw('button6')"><br>
  69. <input class="przycisk" type="button" id="button7" onclick="wstaw('button7')">
  70. <input class="przycisk" type="button" id="button8" onclick="wstaw('button8')">
  71. <input class="przycisk" type="button" id="button9" onclick="wstaw('button9')"><br>
  72. </div>
  73. </body>
  74. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement