Ayuda con TA - TE - TI

:.:-:.:GuIdO:.:+:.:
22 de Septiembre del 2003
Tengo un problema , en una página de códigos de JavaScript encontré un código para hacer un TA - TE - TI. Funcionó bien , pero yo lo modifiqué para que en vez de ser 3 x 3 sea de 4 x 4 ( donde van las X y los O ) bueno , el problema es que no me acepta el código de alerta para poner el cartel , y lo pone cuando terminan , aca mando el código así se fijan bien:

Este es el verdadero:

<html>
<HEAD>
<title>Ta - Te - Ti </title>
<script language="JavaScript">
function redimenciona () {
var h=document.foto.height+20;
var w=document.foto.width+10;
self.resizeTo(w,h);
}
</script>
</HEAD>
<BODY LEFTMARGIN="0" TOPMARGIN="0" MARGINWIDTH="0" MARGINHEIGHT="0">
<CENTER><ONLOAD="redimenciona()"></CENTER>
<SCRIPT name = "JavaScript">
function variables(){
t = 1;
change = 1;
empty1 = -1;
empty2 = -1;
empty3 = -1;
empty4 = -1;
empty5 = -1;
empty6 = -1;
empty7 = -1;
empty8 = -1;
empty9 = -1;
return;
whogoesnow = "Turno: Jugador Nº 1"
}

function win(){
if (empty1==empty2 && empty2==empty3 && empty3==0 ||
empty4==empty5 && empty5==empty6 && empty6==0 ||
empty7==empty8 && empty8==empty9 && empty9==0 ||
empty1==empty4 && empty4==empty7 && empty7==0 ||
empty2==empty5 && empty5==empty8 && empty8==0 ||
empty3==empty6 && empty6==empty9 && empty9==0 ||
empty1==empty5 && empty5==empty9 && empty9==0 ||
empty3==empty5 && empty5==empty7 && empty7==0 ){
alert ("   GANADOR:nJUGADOR Nº 2");
history.go(0)
}
if (empty1==empty2 && empty2==empty3 && empty3==1 ||
empty4==empty5 && empty5==empty6 && empty6==1 ||
empty7==empty8 && empty8==empty9 && empty9==1 ||
empty1==empty4 && empty4==empty7 && empty7==1 ||
empty2==empty5 && empty5==empty8 && empty8==1 ||
empty3==empty6 && empty6==empty9 && empty9==1 ||
empty1==empty5 && empty5==empty9 && empty9==1 ||
empty3==empty5 && empty5==empty7 && empty7==1 ){
alert ("   GANADOR:nJUGADOR Nº 1");
history.go(0)
}
}

function turnchange(t){
if (change == 1) {
if (t == 0){
t = 1;
whogoesnow = "Turno : Jugador Nº " + 1
}
else {
t = 0;
whogoesnow = "Turno : Jugador Nº " + 2
}

}
else {
t = t;
}
change = 1
return (t);
}

function changing(clicked){
if (clicked == 1){
spot = empty1 ;}
if (clicked == 2){
spot = empty2 ;}
if (clicked == 3){
spot = empty3 ;}
if (clicked == 4){
spot = empty4 ;}
if (clicked == 5){
spot = empty5 ;}
if (clicked == 6){
spot = empty6 ;}
if (clicked == 7){
spot = empty7 ;}
if (clicked == 8){
spot = empty8 ;}
if (clicked == 9){
spot = empty9 ;}

if (spot == -1){
if (t == 0){
xo = " O " ;
spot = 0
}
else {
xo = " X " ;
spot = 1
}
if (clicked == 1){
empty1 = spot;}
if (clicked == 2){
empty2 = spot ;}
if (clicked == 3){
empty3 = spot ;}
if (clicked == 4){
empty4 = spot ;}
if (clicked == 5){
empty5 = spot ;}
if (clicked == 6){
empty6 = spot ;}
if (clicked == 7){
empty7 = spot ;}
if (clicked == 8){
empty8 = spot ;}
if (clicked == 9){
empty9 = spot ;}
}
else {
if (spot == 0){
xo = " O ";}
if (spot == 1){
xo = " X ";}
change = 0
}
return (xo) ;
}

function change_b1(form){
clicked = 1;
changing(clicked) ;
t = turnchange(t) ;
form.b1.value = xo;
form.whoseturn.value = whogoesnow
win();
return;
}
function change_b2(form){
clicked = 2;
changing(clicked) ;
form.b2.value = xo;
t = turnchange(t) ;
form.whoseturn.value = whogoesnow
win();
return;
}

function change_b3(form){
clicked = 3;
changing(clicked) ;
form.b3.value = xo;
t = turnchange(t) ;
form.whoseturn.value = whogoesnow
win();
return;
}

function change_b4(form){
clicked = 4;
changing(clicked) ;
form.b4.value = xo;
t = turnchange(t) ;
form.whoseturn.value = whogoesnow
win();
return;
}

function change_b5(form){
clicked = 5;
changing(clicked) ;
form.b5.value = xo;
t = turnchange(t) ;
form.whoseturn.value = whogoesnow
win();
return;
}

function change_b6(form){
clicked = 6;
changing(clicked) ;
form.b6.value = xo;
t = turnchange(t) ;
form.whoseturn.value = whogoesnow
win();
return;
}

function change_b7(form){
clicked = 7;
changing(clicked) ;
form.b7.value = xo;
t = turnchange(t) ;
form.whoseturn.value = whogoesnow
win();
return;
}

function change_b8(form){
clicked = 8;
changing(clicked) ;
form.b8.value = xo;
t = turnchange(t) ;
form.whoseturn.value = whogoesnow
win();
return;
}

function change_b9(form){
clicked = 9;
changing(clicked) ;
form.b9.value = xo;
t = turnchange(t) ;
form.whoseturn.value = whogoesnow
win();
return;
}
</SCRIPT>


<SCRIPT name = "JavaScript">
variables();
</SCRIPT>
<center>
<h1><font color = navy>TA - TE - TI</font></h1>
<FORM>
<input type = "button" name = "whoseturn"
value = "Turno: Jugador Nº 1">
<br><br><br><br>
<table>
<tr><td><input type = "button" name = "b1" value = " " onClick =
change_b1(this.form)>
<td><input type = "button" name = "b2" value = " " onClick =
change_b2(this.form)>
<td><input type = "button" name = "b3" value = " " onClick =
change_b3(this.form)>
<tr><td><input type = "button" name = "b4" value = " " onClick =
change_b4(this.form)>
<td><input type = "button" name = "b5" value = " " onClick =
change_b5(this.form)>
<td><input type = "button" name = "b6" value = " " onClick =
change_b6(this.form)>
<tr><td><input type = "button" name = "b7" value = " " onClick =
change_b7(this.form)>
<td><input type = "button" name = "b8" value = " " onClick =
change_b8(this.form)>
<td><input type = "button" name = "b9" value = " "
onClick = change_b9(this.form)>
</table>
<br><br><br>

<INPUT TYPE="button" VALUE="Nuevo Partido" onClick="history.go(0)">
<br><br><br>

</body>
</html>

Y este el otro que hice yo:

<html>
<HEAD>
<title>Ta - Te - Ti </title>
<script language="JavaScript">
function redimenciona () {
var h=document.foto.height+20;
var w=document.foto.width+10;
self.resizeTo(w,h);
}
</script>
</HEAD>
<BODY LEFTMARGIN="0" TOPMARGIN="0" MARGINWIDTH="0" MARGINHEIGHT="0">
<CENTER><ONLOAD="redimenciona()"></CENTER>
<SCRIPT name = "JavaScript">
function variables(){
t = 1;
change = 1;
empty1 = -1;
empty2 = -1;
empty3 = -1;
empty4 = -1;
empty5 = -1;
empty6 = -1;
empty7 = -1;
empty8 = -1;
empty9 = -1;
empty10 = -1;
empty11 = -1;
empty12 = -1;
empty13 = -1;
empty14 = -1;
empty15 = -1;
empty16 = -1;
return;
whogoesnow = "Turno: Jugador Nº 1"
}

function win(){
if (empty1==empty2 && empty2==empty3 && empty3==empty4 && empty4==0 ||
empty5==empty6 && empty6==empty7 && empty7==empty8 && empty8==0 ||
empty9==empty10 && empty10==empty11 && empty11==empty12 && empty12==0 ||
empty13==empty14 && empty14==empty15 && empty15==empty16 && empty16==0 ||
empty1==empty6 && empty6==empty11 && empty11==empty16 && empty16==0 ||
empty4==empty7 && empty7==empty10 && empty10==empty13 && empty13==0 ||
empty1==empty5 && empty5==empty9 && empty9==empty13 && empty13==0 ||
empty2==empty6 && empty6==empty10 && empty10==empty14 && empty14==0 ||
empty3==empty7 && empty7==empty11 && empty11==empty15 && empty15==0 ||
empty4==empty8 && empty8==empty12 && empty12==empty16 && empty16==0 ){
alert ("   GANADOR:nJUGADOR Nº 1");
history.go(0)
}
if (empty1==empty2 && empty2==empty3 && empty3==empty4 && empty4==0 ||
empty5==empty6 && empty6==empty7 && empty7==empty8 && empty8==0 ||
empty9==empty10 && empty10==empty11 && empty11==empty12 && empty12==0 ||
empty13==empty14 && empty14==empty15 && empty15==empty16 && empty16==0 ||
empty1==empty6 && empty6==empty11 && empty11==empty16 && empty16==0 ||
empty4==empty7 && empty7==empty10 && empty10==empty13 && empty13==0 ||
empty1==empty5 && empty5==empty9 && empty9==empty13 && empty13==0 ||
empty2==empty6 && empty6==empty10 && empty10==empty14 && empty14==0 ||
empty3==empty7 && empty7==empty11 && empty11==empty15 && empty15==0 ||
empty4==empty8 && empty8==empty12 && empty12==empty16 && empty16==0 ){
alert ("   GANADOR:nJUGADOR Nº 2");
history.go(0)
}
}

function turnchange(t){
if (change == 1) {
if (t == 0){
t = 1;
whogoesnow = "Turno : Jugador Nº " + 1
}
else {
t = 0;
whogoesnow = "Turno : Jugador Nº " + 2
}

}
else {
t = t;
}
change = 1
return (t);
}

function changing(clicked){
if (clicked == 1){
spot = empty1 ;}
if (clicked == 2){
spot = empty2 ;}
if (clicked == 3){
spot = empty3 ;}
if (clicked == 4){
spot = empty4 ;}
if (clicked == 5){
spot = empty5 ;}
if (clicked == 6){
spot = empty6 ;}
if (clicked == 7){
spot = empty7 ;}
if (clicked == 8){
spot = empty8 ;}
if (clicked == 9){
spot = empty9 ;}
if (clicked == 10){
spot = empty10 ;}
if (clicked == 11){
spot = empty11 ;}
if (clicked == 12){
spot = empty12 ;}
if (clicked == 13){
spot = empty13 ;}
if (clicked == 14){
spot = empty14 ;}
if (clicked == 15){
spot = empty15 ;}
if (clicked == 16){
spot = empty16 ;}

if (spot == -1){
if (t == 0){
xo = " O " ;
spot = 0
}
else {
xo = " X " ;
spot = 1
}
if (clicked == 1){
empty1 = spot;}
if (clicked == 2){
empty2 = spot ;}
if (clicked == 3){
empty3 = spot ;}
if (clicked == 4){
empty4 = spot ;}
if (clicked == 5){
empty5 = spot ;}
if (clicked == 6){
empty6 = spot ;}
if (clicked == 7){
empty7 = spot ;}
if (clicked == 8){
empty8 = spot ;}
if (clicked == 9){
empty9 = spot ;}
if (clicked == 10){
empty10 = spot ;}
if (clicked == 11){
empty11 = spot ;}
if (clicked == 12){
empty12 = spot ;}
if (clicked == 13){
empty13 = spot ;}
if (clicked == 14){
empty14 = spot ;}
if (clicked == 15){
empty15 = spot ;}
if (clicked == 16){
empty16 = spot ;}
}
else {
if (spot == 0){
xo = " O ";}
if (spot == 1){
xo = " X ";}
change = 0
}
return (xo) ;
}

function change_b1(form){
clicked = 1;
changing(clicked) ;
t = turnchange(t) ;
form.b1.value = xo;
form.whoseturn.value = whogoesnow
win();
return;
}
function change_b2(form){
clicked = 2;
changing(clicked) ;
form.b2.value = xo;
t = turnchange(t) ;
form.whoseturn.value = whogoesnow
win();
return;
}

function change_b3(form){
clicked = 3;
changing(clicked) ;
form.b3.value = xo;
t = turnchange(t) ;
form.whoseturn.value = whogoesnow
win();
return;
}

function change_b4(form){
clicked = 4;
changing(clicked) ;
form.b4.value = xo;
t = turnchange(t) ;
form.whoseturn.value = whogoesnow
win();
return;
}

function change_b5(form){
clicked = 5;
changing(clicked) ;
form.b5.value = xo;
t = turnchange(t) ;
form.whoseturn.value = whogoesnow
win();
return;
}

function change_b6(form){
clicked = 6;
changing(clicked) ;
form.b6.value = xo;
t = turnchange(t) ;
form.whoseturn.value = whogoesnow
win();
return;
}

function change_b7(form){
clicked = 7;
changing(clicked) ;
form.b7.value = xo;
t = turnchange(t) ;
form.whoseturn.value = whogoesnow
win();
return;
}

function change_b8(form){
clicked = 8;
changing(clicked) ;
form.b8.value = xo;
t = turnchange(t) ;
form.whoseturn.value = whogoesnow
win();
return;
}

function change_b9(form){
clicked = 9;
changing(clicked) ;
form.b9.value = xo;
t = turnchange(t) ;
form.whoseturn.value = whogoesnow
win();
return;
}

function change_b10(form){
clicked = 10;
changing(clicked) ;
form.b10.value = xo;
t = turnchange(t) ;
form.whoseturn.value = whogoesnow
win();
return;
}

function change_b11(form){
clicked = 11;
changing(clicked) ;
form.b11.value = xo;
t = turnchange(t) ;
form.whoseturn.value = whogoesnow
win();
return;
}

function change_b12(form){
clicked = 12;
changing(clicked) ;
form.b12.value = xo;
t = turnchange(t) ;
form.whoseturn.value = whogoesnow
win();
return;
}

function change_b13(form){
clicked = 13;
changing(clicked) ;
form.b13.value = xo;
t = turnchange(t) ;
form.whoseturn.value = whogoesnow
win();
return;
}

function change_b14(form){
clicked = 14;
changing(clicked) ;
form.b14.value = xo;
t = turnchange(t) ;
form.whoseturn.value = whogoesnow
win();
return;
}

function change_b15(form){
clicked = 15;
changing(clicked) ;
form.b15.value = xo;
t = turnchange(t) ;
form.whoseturn.value = whogoesnow
win();
return;
}

function change_b16(form){
clicked = 16;
changing(clicked) ;
form.b16.value = xo;
t = turnchange(t) ;
form.whoseturn.value = whogoesnow
win();
return;
}
</SCRIPT>


<SCRIPT name = "JavaScript">
variables();
</SCRIPT>
<center>
<h1><font color = navy>TA - TE - TI</font></h1>
<FORM>
<input type = "button" name = "whoseturn"
value = "Turno: Jugador Nº 1">
<br><br><br><br>
<table>
<tr><td><input type = "button" name = "b1" value = " " onClick =
change_b1(this.form)>
<td><input type = "button" name = "b2" value = " " onClick =
change_b2(this.form)>
<td><input type = "button" name = "b3" value = " " onClick =
change_b3(this.form)>
<td><input type = "button" name = "b4" value = " " onClick =
change_b4(this.form)>
<tr><td><input type = "button" name = "b5" value = " " onClick =
change_b5(this.form)>
<td><input type = "button" name = "b6" value = " " onClick =
change_b6(this.form)>
<td><input type = "button" name = "b7" value = " " onClick =
change_b7(this.form)>
<td><input type = "button" name = "b8" value = " " onClick =
change_b8(this.form)>
<tr><td><input type = "button" name = "b9" value = " "
onClick = change_b9(this.form)>
<td><input type = "button" name = "b10" value = " "
onClick = change_b10(this.form)>
<td><input type = "button" name = "b11" value = " "
onClick = change_b11(this.form)>
<td><input type = "button" name = "b12" value = " "
onClick = change_b12(this.form)>
<tr><td><input type = "button" name = "b13" value = " "
onClick = change_b13(this.form)>
<td><input type = "button" name = "b14" value = " "
onClick = change_b14(this.form)>
<td><input type = "button" name = "b15" value = " "
onClick = change_b15(this.form)>
<td><input type = "button" name = "b16" value = " "
onClick = change_b16(this.form)>
</table>
<br><br><br>

<INPUT TYPE="button" VALUE="Nuevo Partido" onClick="history.go(0)">
<br><br><br>

</body>
</html>