-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
96 lines (90 loc) · 2.67 KB
/
test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<html>
<style>
body{
background: dodgerblue;
}
.main{
margin-left:37%;
margin-right: 36%;
margin-top:20%;
}
.game{
padding: 30px;
padding-left: 100px;
}
.btn{
width: 60px;
height: 60px;
padding: 0px;}
</style>
<body>
<div class="main">
<div class="game">
<input type="button" class="btn" onclick="puta(1)" id="1" value="-">
<input type="button" class="btn" onclick="puta(2)" id="2" value="-">
<input type="button" class="btn" onclick="puta(3)" id="3" value="-"><br>
<input type="button" class="btn" onclick="puta(4)" id="4" value="-">
<input type="button" class="btn" onclick="puta(5)" id="5" value="-">
<input type="button" class="btn" onclick="puta(6)" id="6" value="-"><br>
<input type="button" class="btn" onclick="puta(7)" id="7" value="-">
<input type="button" class="btn" onclick="puta(8)" id="8" value="-">
<input type="button" class="btn" onclick="puta(9)" id="9" value="-"><br>
</div>
</div>
<script>
var i=0;
var counter=0;
function puta(n)
{ if(i==0)
document.getElementById(n).value='X';
else
{
document.getElementById(n).value='O';
}
document.getElementById(n).disabled = true;
i++;
if(i>1)
i=0;
a=document.getElementById(1).value
b= document.getElementById(2).value
c= document.getElementById(3).value
d= document.getElementById(4).value
e= document.getElementById(5).value
f= document.getElementById(6).value
g= document.getElementById(7).value
h= document.getElementById(8).value
j=document.getElementById(9).value
if(counter>0){
if(a.localeCompare(b)==0 && b.localeCompare(c)==0 && a!="-" && b!="-" && c!="-")
{
alert(a+" WINS THE GAME");
}
if(d.localeCompare(e)==0 && e.localeCompare(f)==0 && d!="-" && e!="-" && f!="-")
{
alert(d+" WINS THE GAME");
}
if(g.localeCompare(h)==0 && h.localeCompare(j)==0 && g!="-" && h!="-" && j!="-")
{
alert(g+" WINS THE GAME");
}if(a.localeCompare(d)==0 && d.localeCompare(g)==0 && a!="-" && d!="-" && g!="-")
{
alert(a+" WINS THE GAME");
}if(b.localeCompare(e)==0 && e.localeCompare(h)==0 && b!="-" && e!="-" && h!="-")
{
alert(b+" WINS THE GAME");
}if(c.localeCompare(f)==0 && f.localeCompare(j)==0 && c!="-" && f!="-" && j!="-")
{
alert(c+" WINS THE GAME");
}if(a.localeCompare(e)==0 && e.localeCompare(j)==0 && a!="-" && e!="-" && j!="-")
{
alert(a+" WINS THE GAME");
}if(c.localeCompare(e)==0 && e.localeCompare(g)==0 && c!="-" && e!="-" && g!="-")
{
alert(c+" WINS THE GAME");
}
}
counter++;
}
</script>
</body>
</html>