<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import = "javax.swing.*" import="DefaultNamespace.user"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Play Tic-Tac-Toe</title>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0"
align="center">
<tr>
<td> </td>
</tr>
<tr>
<td>
<div align="center">
<font color="#19A1CB" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<span><b>Tic Tac Toe Game</b></span><br></br>
<span>Click on the box to play the game</span><br></br>
</font>
<FORM NAME="tic"><INPUT TYPE="button" NAME="sqr1" class="tictac"
value=" "
onClick=valChange()>
<INPUT TYPE="button" NAME="sqr2" class="tictac" value=" " size="50"
onClick="">
<INPUT TYPE="button" NAME="sqr3" class="tictac" value=" "
onClick=""><br>
<INPUT TYPE="button" NAME="sqr4" class="tictac" value=" "
onClick="">
<INPUT TYPE="button" NAME="sqr5" class="tictac" value=" "
onClick="">
<INPUT TYPE="button" NAME="sqr6" class="tictac" value=" "
onClick=""><br>
<INPUT TYPE="button" NAME="sqr7" class="tictac" value=" "
onClick="">
<INPUT TYPE="button" NAME="sqr8" class="tictac" value=" "
onClick="">
<INPUT TYPE="button" NAME="sqr9" class="tictac" value=" "
onClick="">
<br></br>
<br>
<br></br>
<input type="button" name="pl1" Value="Player1 DoMove"
onClick="this.disabled=true,tic.pl2.disabled=false"></input>
<input type="button" name="pl2" value="Player2 DoMove" class="tictac"
onClick="this.disabled=true,tic.pl1.disabled=false"></input>
<script language="javascript" type="text/javascript">
tic.pl2.disabled="true";
</script>
<SCRIPT language="javascript" >
function valChange()
{
if(tic.pl1.disabled==true && tic.sqr1.value==" ")
{
tic.sqr1.value=" X ";
}
else if(tic.pl2.disabled==true && tic.sqr1.value==" ")
{
tic1.sqr1.value=" 0 ";
}
}
</SCRIPT>
</form>
</div>
</td>
</tr>
<tr height=30><td></td></tr>
<tr>
<td>
</td>
</tr>
</table>
</body>
</html>
I am new to JSP..
the code works as per expected when the button pl1 is disabled i.e. it displays X on clicking sqr1..but it doesnt display 0 on clicking sqr1 when button pl2 is disabled.
so wats wrong in the above code