Hey guys sorry to have to ask but im at college and my teachers a d1ck he hasnt explained how to do this so i was wondering if anyone could explain how i go about it..
Its basically about noughts and crosses game in xhtml and where writing the table in javascript. We only started looking at javascript last week and he just threw this at us and said make it work ?
😮 THANKS!! lol,
Hopefully somone can explain better than my idiot of a so called “TEACHER”
[code]
<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE html
PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”>
<head>
<title>Noughts & Crosses</title>
<script type = “text/javascript”>
//Noughts and Crosses MVH 2007-11-30
//Draw the box
var matrix_width = “100px”
var matrix_height = “100px”
document.write(‘<style type=”text/css”>’);
document.write(‘.size {width:’);
document.write(matrix_width);
document.write(‘;height:’);
document.write(matrix_height);
document.write(‘;border:solid’);
document.write(‘</style>’);
//End of Draw the box
//Setup array of squares. These must be global variables
//Each square will be in one of three states: _blank || _nought || _cross
var squares = new Array(9);
for (i=0;i<=8;i++)
{
squares[i] =”_blank”;
}
alert(squares[0]);
alert(squares[8]);
function enter_mark(square)
{
var id=”sq_”+ square;
document.getElementById(id).style.backgroundColor=”#FFCC80″;
squares[square] =”_cross”;
alert(squares[square]);
}
</script>
<style type = “text/css”>
#sq_0 {position:absolute;left:100px;top:100px}
#sq_1 {position:absolute;left:200px;top:100px}
#sq_2 {position:absolute;left:300px;top:100px}
#sq_3 {position:absolute;left:100px;top:200px}
#sq_4 {position:absolute;left:200px;top:200px}
#sq_5 {position:absolute;left:300px;top:200px}
#sq_6 {position:absolute;left:100px;top:300px}
#sq_7 {position:absolute;left:200px;top:300px}
#sq_8 {position:absolute;left:300px;top:300px}
</style>
</head>
</html>