/    Sign up×
Community /Pin to ProfileBookmark

Javascript help..

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 &amp; 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>
[/code]

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@KorJan 17.2008 — You forgot to tell us what in fact is your problem. What can we do for you?
Copy linkTweet thisAlerts:
@Sy-RedmanauthorJan 17.2008 — Oh sorry lol well basically he just asked us to make it work... its supposed to come up with 9 boxes and for yu to be able to get an error message but all that happens is u get a message saying _blank twice when u first go onto the page i dont really know whats going on or where to start i understand a "little" of javascript but i dont know what to do with this..

thankd ?
Copy linkTweet thisAlerts:
@Sy-RedmanauthorJan 17.2008 — Sorry im not too good at explaining things i know..

The problem is i just dont know how to make it work because i dont understand whats hes done...

Thanks jack
×

Success!

Help @Sy-Redman spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.23,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...