Не работает if-else
Добрый день. Пытаюсь написать крестики-нолики. Не могу понять: почему не работает присвоение "Х" или "0" при четном-нечетном ходу в if-else.
Очень прошу помощи у знатоков. Спасибо.
<!DOCTYPE>
<html>
<head>
<title>Крестики-нолики</title>
<meta charset="utf-8">
</head>
<body>
<form>
<table height="" width="" border="0">
<tr>
<td> <input type="button" name="b1" value="" onclick="event_b1(form)"> </td>
<td> <input type="button" name="b2" value="" onclick="event_b2(form)"> </td>
<td> <input type="button" name="b3"value="" onclick="event_b3(form)"> </td>
</tr>
<tr>
<td><input type="button" name="b4"value="" onclick="event_b4(form)"></td>
<td><input type="button" name="b5"value="" onclick="event_b5(form)"></td>
<td><input type="button" name="b6"value="" onclick="event_b6(form)"></td>
</tr>
<tr>
<td><input type="button" name="b7"value="" onclick="event_b7(form)"></td>
<td><input type="button" name="b8"value="" onclick="event_b8(form)"></td>
<td><input type="button" name="b9"value="" onclick="event_b9(form)"></td>
</tr>
</table>
</form>
<script>
var hod = 0;
function event_b1 (form){
if (hod%2 == 0){
form.b1.value = "X";
} else {
form.b1.value = "0";
}
}
hod++;
function event_b2 (form){
if (hod%2 == 0){
form.b2.value = "X";
} else {
form.b2.value = "0";
}
}
hod++;
function event_b3 (form){
if (hod%2 == 0){
form.b3.value = "X";
} else {
form.b3.value = "0";
}
}
hod++;
function event_b4 (form){
if (hod%2 == 0){
form.b4.value = "X";
} else {
form.b4.value = "0";
}
}
hod++;
function event_b5 (form){
if (hod%2 == 0){
form.b5.value = "X";
} else {
form.b5.value = "0";
}
}
hod++;
function event_b6 (form){
if (hod%2 == 0){
form.b6.value = "X";
} else {
form.b6.value = "0";
}
}
hod++;
function event_b7 (form){
if (hod%2 == 0){
form.b7.value = "X";
} else {
form.b7.value = "0";
}
}
hod++;
function event_b8 (form){
if (hod%2 == 0){
form.b8.value = "X";
} else {
form.b8.value = "0";
}
}
hod++;
function event_b9 (form){
if (hod%2 == 0){
form.b9.value = "X";
} else {
form.b9.value = "0";
}
}
</script>
</body>
</html>
|