/    Sign up×
Community /Pin to ProfileBookmark

help me debug my javascript game please!

I’ve been @ this now for 2 days straight.. and i’m tierd, but I have to finish this game, its got errors I can’t fix….I got the orginal game from the internet and kinda like got 2 versions of it, but different styles and sourcecode…and i changed a little to more or less customize what i want.. now it just won’t work… Help a girl out please! or email me @ [email][email protected][/email]
thanks
if you think you can help… please leave a msg here or an email where i can send it to you at.

to post a comment
JavaScript

46 Comments(s)

Copy linkTweet thisAlerts:
@pyroMar 31.2003 — You told us absolutly nothing except that you code doesn't work. We will need either a link or some code to be able to give you any help... :rolleyes:
Copy linkTweet thisAlerts:
@laurenauthorMar 31.2003 — this is my disastrous code... well actually, i changed the coding of 2 orignal versions of this game, so that i could try out something with the alphabet... but so far, i cant even get this one with numbers to work!

<html>

<head>

<title>Untitled Document</title>

<meta http-equiv="Content-Type" content="teOt/html; charset=iso-8859-1">




<SCRIPT LANGUAGE="JavaScript">

<!-- Begin

var O = "http://www.geocities.com/mywebsite.gif";

// Location of where you uploaded your site's O.jpg image

var redB = "http://www.geocities.com/mywebsite.gif";

// Location of where you uploaded your site's o.jpg image

var K = "http://www.geocities.com/mywebsitegre1.gif";

// Location of where you uploaded your site's redB.gif image


var pause = 0;

var all = 0;

var box1 = 0;

var box2 = 0;

var box3 = 0;

var box4 = 0;

var box5 = 0;

var box6 = 0;

var box7 = 0;

var box8 = 0;

var box9 = 0;

var temp="";

var ok = 0;

var cf = 0;

var choice=9;

var aRandomNumber = 0;

var comp = 0;

var t = 0;

var wn = 0;

var ls = 0;

var ts = 0;

function help() {

alert("help file")

}




var FPlayer=prompt(" What's your name?","player1")

var SPlayer=prompt(" What are the circles going to be called?","player2")

var boxalert456="Heyyyy you win this time!"+FPlayer+", with box4, box5, and box6"

var boxalert417="Heyyyy you win this time!" +FPlayer+", with box1, box4, and box7"


var boxalert258="Heyyyy you win this time!" +FPlayer+", with box2, box5, and box8"


var boxalert123="Heyyyy you win this time!" +FPlayer+", with box1, box2 and box3"


var boxalert159="Heyyyy you win this time!" +FPlayer+", with box1, box5, and box9"


var boxalert369="Heyyyy you win this time!" +FPlayer+", with box3, box6, and box9"

var boxalert789="Heyyyy you win this time!" +FPlayer+", with box7, box8, and box9"

var boxOalert357="Heyyyy you win this time!" +FPlayer+", with box3, box5, and box7"


function hit1(){

if(box1.value==""){

box1.value=" O "

}else{

alert("Oops, theres already an O there!")

}

if(box1.value==" O " && box2.value==" O " && box3.value==" O "){

alert(boxalert123)

if(confirm(" Lets play again!! ")){

startAgain()

}else{

alert("Awww, mannn *sighs* ")

}

}else

if(box1.value==" O " && box5.value==" O " && box9.value==" O "){

alert(boxalert159)

if(confirm(" Lets play again!! ")){

startAgain()

}else{

alert("Awww, mannn sighs ")

}

}else

if(box1.value==" O " && box4.value==" O " && box7.value==" O "){

alert(boxalert417)

if(confirm(" Lets play again!! ")){

startAgain()

}else{

alert("Awww, mannn *sighs* ")

}

}else{

circle()

}

}

function hit2(){

if(box2.value==""){

box2.value=" "

}else{

alert("Oops, theres already an O there!")

}

if(box2.value==" O " && box1.value==" O " && box3.value==" O "){

alert(boxalert123)

}else

if(box2.value==" O " && box5.value==" O " && box8.value==" O "){

alert(boxalert258)

}else{

circle()

}

}

function hit3(){

if(box3.value==""){

box3.value=" O "

}else{

alert("Oops, theres already an O there!")

}

if(box3.value==" O " && box2.value==" O " && box1.value==" O "){

alert(boxalert123)

if(confirm(" Lets play again!! ")){

startAgain()

}else{

alert("Awww, mannn *sighs* ")

}

}else

if(box3.value==" O " && box6.value==" O " && box9.value==" O "){

alert(boxalert369)

if(confirm(" Lets play again!! ")){

startAgain()

}else{

alert("Awww, mannn *sighs* ")

}

}else

if(box3.value==" O " && box5.value==" O " && box7.value==" "){

alert(boxalert357)

if(confirm(" Lets play again!! ")){

startAgain()

}else{

alert("Awww, mannn *sighs* ")

}

}else{

circle()

}

}

function hit4(){

if(box4.value==""){

box4.value=" O "

}else{

alert("Oops, theres already an O there!")

}

if(box4.value==" O " && box1.value==" O " && box7.value==" O "){

alert(boxalert417)

if(confirm(" Lets play again!! ")){

startAgain()

}else{

alert("Awww, mannn *sighs* ")

}

}else

if(box4.value==" O " && box5.value==" O " && box6.value==" O "){

alert(boxalert456)

if(confirm(" Lets play again!! ")){

startAgain()

}else{

alert("Awww, mannn *sighs* ")

}

}else{

circle()

}

}

function hit5(){

if(box5.value==""){

box5.value=" O "

}else{

alert("Oops, theres already an O there!")

}

if(box5.value==" O " && box4.value==" O " && box6.value==" O "){

alert(boxalert456)

if(confirm(" Lets play again!! ")){

startAgain()

}else{

alert("Awww, mannn *sighs* ")

}

}else

if(box5.value==" O " && box2.value==" O " && box8.value==" O "){

alert(boxalert258)

if(confirm(" Lets play again!! ")){

startAgain()

}else{

alert("Awww, mannn *sighs* ")

}

}else

if(box3.value==" O " && box5.value==" O " && box7.value==" O "){

alert(boxalert357)

if(confirm(" Lets play again!! ")){

startAgain()

}else{

alert("Awww, mannn *sighs* ")

}

}else

if(box1.value==" O " && box5.value==" O " && box9.value==" O "){

alert(boxalert159)

if(confirm(" Lets play again!! ")){

startAgain()

}else{

alert("Awww, mannn *sighs* ")

}

}else{

circle()

}

}

function hit6(){

if(box6.value==""){

box6.value=" x "

}else{

alert("Oops, theres already an x there!")

}

if(box6.value==" x " && box3.value==" x " && box9.value==" x "){

alert(boxalert369)

if(confirm(" Lets play again!! ")){

startAgain()

}else{

alert("Awww, mannn *sighs* ")

}

}else

if(box4.value==" x " && box5.value==" x " && box6.value==" "){

alert(boxalert456)

if(confirm(" Lets play again!! ")){

startAgain()

}else{

alert("Awww, mannn *sighs* ")

}

}else{

circle()

}

}

function hit7(){

if(box7.value==""){

box7.value=" x "

}else{

alert("Oops, theres already an x there!")

}

if(box7.value==" x " && box4.value==" x " && box1.value==" x "){

alert(boxalert417)

if(confirm(" Lets play again!! ")){

startAgain()

}else{

alert("Awww, mannn *sighs* ")

}

}else

if(box7.value==" x " && box5.value==" x " && box3.value==" x "){

alert(boxalert357)

if(confirm(" Lets play again!! ")){

startAgain()

}else{

alert("Awww, mannn *sighs* ")

}

}else

if(box7.value==" x " && box8.value==" x " && box9.value==" x "){

alert(boxalert789)

if(confirm(" Lets play again!! ")){

startAgain()

}else{

alert("Awww, mannn *sighs* ")

}

}else{

circle()

}

}

function hit8(){

if(box8.value==""){

box8.value=" x "

}else{

alert("Oops, theres already an x there!")

}

if(box8.value==" x " && box7.value==" x " && box9.value==" x "){

alert(boxalert789)

if(confirm(" Lets play again!! ")){

startAgain()

}else{

alert("Awww, mannn *sighs* ")

}

}else

if(box8.value==" x " && box5.value==" x " && box2.value==" x "){

alert(boxalert258)

if(confirm(" Lets play again!! ")){

startAgain()

}else{

alert("Awww, mannn *sighs* ")

}

}else{

circle()

}

}

function hit9(){

if(box9.value==""){

box9.value=" x "

}else{

alert("Oops, theres already an x there!")

}

if(box9.value==" x " && box6.value==" x " && box3.value==" x "){

alert(boxalert369)

if(confirm(" Lets play again!! ")){

startAgain()

}else{

alert("Awww, mannn *sighs* ")

}

}else

if(box9.value==" x " && box8.value==" x " && box7.value==" x "){

alert(boxalert789)

if(confirm(" Lets play again!! ")){

startAgain()

}else{

alert("Awww, mannn *sighs* ")

}

}else

if(box9.value==" x " && box5.value==" x " && box1.value==" x "){

alert(boxalert159)

if(confirm(" Lets play again!! ")){

startAgain()

}else{

alert("Awww, mannn *sighs* ")

}

alert("Awww, mannn *sighs* ")

}

}

function startAgain(){

box1.value=""

box2.value=""


box3.value=""

box4.value=""

box5.value=""

box6.value=""

box7.value=""

box8.value=""

box9.value=""

}


}

function rematch() {

if (all==0) {

if(confirm("restarting?")) reset();

}

if (all>0) startnew();

}

function startnew() {

all = 0;

a = 0;

b = 0;

c = 0;

d = 0;

e = 0;

f = 0;

g = 0;

h = 0;

i = 0;

temp="";

ok = 0;

cf = 0;

choice=9;

aRandomNumber = 0;

comp = 0;

document.images.1.src= redB;

document.images.2.src= redB;

document.images.3.src= redB;

document.images.4.src= redB;

document.images.5.src= redB;

document.images.6.src= redB;

document.images.7.src= redB;

document.images.8.src= redB;

document.images.9.src= redB;



t--;

}

}

// End -->

</script>

</head>

<body>

<center>

<form name=game>

<table border=0>

<td>

<table border=1>

<tr>

<td><a href="box('1')"><img src="redB.gif" border=0 height=54 width=54 name=box1 alt="Top-Left"></a></td>

<td><a href="box('2')"><img src="redB.gif" border=0 height=54 width=54 name=box2 alt="Top-Center"></a></td>

<td><a href="box('3')"><img src="redB.gif" border=0 height=54 width=54 name=box3 alt="Top-Right"></a></td>

</tr>

<tr>

<td><a href="box('4')"><img src="redB.gif" border=0 height=54 width=54 name=4 alt="Middle-Left"></a></td>

<td><a href="box('5')"><img src="redB.gif" border=0 height=54 width=54 name=5 alt="Middle-Center"></a></td>

<td><a href="box('6')"><img src="redB.gif" border=0 height=54 width=54 name=6 alt="Middle-Right"></a></td>

</tr>

<tr>

<td><a href="box('7')"><img src="redB.gif" border=0 height=54 width=54 name=G alt="Bottom-Left"></a></td>

<td><a href="box('8')"><img src="redB.gif" border=0 height=54 width=54 name=H alt="Bottom-Center"></a></td>

<td><a href="box('9')"><img src="redB.gif" border=0 height=54 width=54 name=I alt="Bottom-Right"></a></td>

</tr>

</table>

</td>

<td>&nbsp; </td>

</table>

</form>

</center>

<p><center>

</center><p>



</body>

</html>
Copy linkTweet thisAlerts:
@laurenauthorMar 31.2003 — everyone who keeps viewing this page but not posting... help me please!
Copy linkTweet thisAlerts:
@pyroMar 31.2003 — I didn't look at the script for long enough to check what it is suppose to be doing, but I did check my browser for error messages, and here are some things you need to chage:

[color=darkred]Line 354:[/color] You have an extra [color=darkblue]}[/color]

[color=darkred]Line 378-386:[/color] You have [color=darkblue]document.images.1.src= redB;[/color]

...

when the correct syntax is [color=darkblue]document.images[1].src= redB;[/color]

...

Also, arrays start with 0, rather than 1.

[color=darkred]Line 354:[/color] You have an extra [color=darkblue]}[/color]
Copy linkTweet thisAlerts:
@laurenauthorMar 31.2003 — see it works right, but its not doing anything, when i click a box, it just takes me to a blank white page. its supposed to be a game of noughts and crosses, so when you press one red square, a nought should come up, and the computers cross comes up, thats whats supposed to be happeneing, and although there are no error messages right now, it doesnt actually do what its supposed to do...what can i do?
Copy linkTweet thisAlerts:
@cyberadeMar 31.2003 — All of the 'href's reference "box['n']" but you don't have a function called "box".
Copy linkTweet thisAlerts:
@laurenauthorMar 31.2003 — when i change the href's to 'hit' which is what i just realised my functions were... it still brings me to a white screen when i click one of the boxes.. i'm stuck ?
Copy linkTweet thisAlerts:
@pyroMar 31.2003 — [i]Originally posted by lauren [/i]

[B]...and although there are no error messages right now...[/B][/QUOTE]
There were for me...
Copy linkTweet thisAlerts:
@laurenauthorMar 31.2003 — so what shall i doooooo?

i just want it to work as a proper game ?
Copy linkTweet thisAlerts:
@laurenauthorMar 31.2003 — pyro, i made the changes that you suggested. and did other stuff that i thought would help it to work...

but still when i click a box, it brings me to a white page... what is supposed to happen when i click a box, is that it is supposed to bring up a nought or cross in a different colour....
Copy linkTweet thisAlerts:
@pyroMar 31.2003 — A couple more things you can try...

Chage [color=darkblue]<a href="box('1')">

<a href="box('2')">

...[/color]


to [color=darkblue]<a href="#" onClick="hit1(); return false;">

<a href="#" onClick="hit2(); return false;">

...[/color]


Also, you don't have any function circles() which you are calling in each hitx() function.
Copy linkTweet thisAlerts:
@AdamBrillMar 31.2003 — Try the attached code and see if that works. If it still doesn't work right, could you attach the graphics? It definately doesn't work right without those. ?

[upl-file uuid=01af9c74-28cd-4690-9c55-5cdbc015308f size=9kB]index.txt[/upl-file]
Copy linkTweet thisAlerts:
@laurenauthorMar 31.2003 — this is the first image

[upl-file uuid=af35b048-a066-4f91-9d35-87a4cbbc4178 size=168B]gre1.gif[/upl-file]
Copy linkTweet thisAlerts:
@laurenauthorMar 31.2003 — 2nd..

[upl-file uuid=bfeaba3f-3ecd-46a0-8dc8-094150e2514a size=161B]blu0.gif[/upl-file]
Copy linkTweet thisAlerts:
@laurenauthorMar 31.2003 — that address, is where my images are hosted @... theres 3 of them.

http://www.geocities.com/laurenkadyharper/redB.gif

[upl-file uuid=746e1d6e-8d97-48a1-9915-5ebb345ea684 size=122B]redb.gif[/upl-file]
Copy linkTweet thisAlerts:
@laurenauthorMar 31.2003 — last image.

[upl-file uuid=9af8781c-c215-4fd0-bce4-ab9ad9f78a94 size=122B]redb.gif[/upl-file]
Copy linkTweet thisAlerts:
@laurenauthorMar 31.2003 — pyro... when i change it to false... i get a new error message saying "object doesnt support this property or method"......

?
Copy linkTweet thisAlerts:
@AdamBrillMar 31.2003 — What kind of game is this?? It doesn't do anything. For one thing, you don't have the circle function in there... Do you have that?
Copy linkTweet thisAlerts:
@laurenauthorMar 31.2003 — i know it doesnt do anything... thats the problem...

u can see an example of what is supposed to happen here...

http://javascript.internet.com/games/tic-tac-toe.html
Copy linkTweet thisAlerts:
@AdamBrillMar 31.2003 — What are you trying to modify? Or are you just trying to get that to work?
Copy linkTweet thisAlerts:
@laurenauthorMar 31.2003 — I'm just tryna get it to work.. I don't know if i have missed out coding which is why it won't work...
Copy linkTweet thisAlerts:
@AdamBrillApr 01.2003 — Try this code. Just extract it and run the index.htm. I hope that helps. ?

[upl-file uuid=343e1cf0-a96e-443a-9386-8887b899f141 size=18kB]tic-tac-toe.zip[/upl-file]
Copy linkTweet thisAlerts:
@laurenauthorApr 01.2003 — thank you. that does work, because its the original game. that does mean my code is a lost course?
Copy linkTweet thisAlerts:
@AdamBrillApr 01.2003 — Well, your code was kind of messed up. ? Did you want to modify the original? If so, I can help you do whatever it is you wanted to do... ?
Copy linkTweet thisAlerts:
@laurenauthorApr 01.2003 — lol @ my messed up code!

but modifying the original so it isn't exactly the same would be great!
Copy linkTweet thisAlerts:
@AdamBrillApr 01.2003 — Well.... What do you want me to modify? Or should I just do some random modifications? ? What do you want the game for?
Copy linkTweet thisAlerts:
@laurenauthorApr 01.2003 — *thinks* ermmm.. random modifications would be good!

i just want it so that the code doesn't look exactly the same as the original! which is where my funny looking code came into it, and it went all pear shaped! lol the game is part of my learning package for children, and i would get a slap on the wrist from my teacher if he knew i copied the code word for word from the internet, hence that mess i made ?. lol
Copy linkTweet thisAlerts:
@laurenauthorApr 01.2003 — oh and also, the images i want to use are already in this forum on this page. its redB which is blank, bluO which is blue with a green 0 in, and gre1 which is green with a blue 1 inside, or it might be the other way round.. not too sure ?
Copy linkTweet thisAlerts:
@AdamBrillApr 01.2003 — [i]Originally posted by lauren[/i]

[b]lol the game is part of my learning package for children, and i would get a slap on the wrist from my teacher if he knew i copied the code word for word from the internet, hence that mess i made .[/b][/quote]
You have a teacher that is teaching you how to make a learning package for children??? That sounds a little weird... ? Anyway, do you think your teacher would think it is better if someone on a forums modified the code for you??
Copy linkTweet thisAlerts:
@laurenauthorApr 01.2003 — no...my teacher isn't teaching me how to do the package... i am :s

and no he wouldnt think it was better if someone modifyed the code for me... which is why i tried to code it myself.. but it didnt work ?

i feel like i'm being reprimanded ?
Copy linkTweet thisAlerts:
@AdamBrillApr 01.2003 — [i]Originally posted by lauren[/i]

[b]i feel like i'm being reprimanded[/b][/quote]
That would be about right. ? I think you should take that working copy that I gave you and try to modify it. Then, if you have any problems, you can ask me... Don't modify the whole thing right away; just modify it a little and try it. Repeat as necessary. ?
Copy linkTweet thisAlerts:
@laurenauthorApr 01.2003 — *sighs*

ok

?
Copy linkTweet thisAlerts:
@AdamBrillApr 01.2003 — lol ? I don't want to get in trouble with your teacher... ?
Copy linkTweet thisAlerts:
@laurenauthorApr 01.2003 — you won't!

its just that i have tried doing the code myself, and it won't work. the one on that website is wayyyyy to confusing for me to try and understand to the point of re-writing... hence my lil mess up i suppose

?
Copy linkTweet thisAlerts:
@AdamBrillApr 01.2003 — Maybe I should rephrase... I don't want to get [i]you[/i] in trouble with your teacher. ? Anyway, I said I would help, I just won't do the whole thing. You aren't going to learn very much if I do it... ?
Copy linkTweet thisAlerts:
@laurenauthorApr 01.2003 — *cries*

but i've tried & it doesnt work

?
Copy linkTweet thisAlerts:
@AdamBrillApr 02.2003 — Why don't you talk to your teacher? Maybe he can help you... Or you could ask him if I can help you...
Copy linkTweet thisAlerts:
@laurenauthorApr 02.2003 — lol, my teacher doesn't know anything about programmin! He deals with all those funny looking gadgets inside the baseunit. I'm sure he would not mind if you helped me........
Copy linkTweet thisAlerts:
@AdamBrillApr 02.2003 — Ok, fine. But if you get in trouble, don't blame it on me. ? I was looking at your code again and noticed that you didn't include any of the AI part. Are you going to make it two player? Either way, I corrected your code so it will work now. Look at how I did it... I used WAY fewer lines. Anyway, it only has the O right now, so you can try to add the X and see what happens. Let me know if you have any problems... :p

[upl-file uuid=9c323d75-5f3f-4636-a193-932a540d3d1f size=2kB]code.zip[/upl-file]
Copy linkTweet thisAlerts:
@laurenauthorApr 02.2003 — thank you very much ?..

i can see that it works, because the pop up message appears, but my images don't show up, do you know why that is? i put in my website as to where the images are displayed... by the red boxes don't show up :s
Copy linkTweet thisAlerts:
@AdamBrillApr 02.2003 — Ok, try this code...

[upl-file uuid=7a3d558d-5ed3-41fb-9889-52c2364591f1 size=5kB]game.txt[/upl-file]
Copy linkTweet thisAlerts:
@laurenauthorApr 02.2003 — yes that works, you're a star ?, so all i have to do now is to throw in the coding to get the green box to come up?
Copy linkTweet thisAlerts:
@AdamBrillApr 02.2003 — [i]Originally posted by lauren [/i]

[B]so all i have to do now is to throw in the coding to get the green box to come up? [/B][/QUOTE]
If it were only that easy... ? ?
Copy linkTweet thisAlerts:
@laurenauthorApr 03.2003 — if only it was that easy?!?!?!

what does that mean?!?!?!
Copy linkTweet thisAlerts:
@AdamBrillApr 03.2003 — That means that it is never as easy as "throwing in some code and it working." ? Actually, I was kidding... ?
Copy linkTweet thisAlerts:
@laurenauthorApr 05.2003 — I give up...

*sighs*

But thank you anyway.
×

Success!

Help @lauren 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.28,
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,
)...