/    Sign up×
Community /Pin to ProfileBookmark

ChessGame: Getting an object required error when reloading after 3rd turn

Hey guys,

i got a little problem with my script, i just had build some website with JavaScript for one of my classes, so came however on the idea to build a simple chessgame … so i’ve done, but there appears a stupid problem, that chessgame got pictures for the figures, better than some stupid words, and what would be better for a chessgame as a table to visualization(the real chess field is an 2 dimenstional array that holds the figure objects), so i’ve used the table to hold the figures as “object”, these function things, so every figure has it object, that holds the color, the name and a path to its picture everything worked fine, till i wanted to move one of these objects, in the moment its only possible to move anyone of that figures on an empty field, u know generally the first turn on every chessgame, the rest wasnt implemented yet.

so under that table are some input text boxes, simply for giving the from to coordiantes of the turn, at least under that is an input button to let make the turn, when the button is pressed, it will be checked if the from to coordinates are allright and if that should be the case, the turn will be done in the way, that the figures in the array on that involved positions will be exchanged, so simply an empty field changes the position with the figure, that would be also written in the table, but the changed table woudnt be shown, so i wrote an onclick option on that input button, that will redraw the whole site, the problem is, that the source code of the objects get lost after first repaint of that site, or reload would be better, i dont know how to fix that, i tested with includes in that way …

[code=php]document.write(“<script src=”ChessGame.js” language=”JavaScript” type=”text/javascript”></script> “);[/code]

but it didnt work, i dont want to take all the source code in that document.write(” … “); thing …after the first chess turn firefox rebuild that site and shows the replaced figure an the right position, but firefox didnt stop loading that site, InternetExplorer loads it in that case succesfull but after the next turn, so the 3rd one appears an “object required error when loading” message in line 7 …

so i know that the source code of that objects get lost, the question is, how to repaint the chess game with full source code, that the objects are known in the 40th turn too?? and that in a solution that only involves JavaScript and HTML, no PHP or other stuff, that would drive my proffessor real crazy ? hmm i think not really my problem, but it effects on my mark for that site ?

so all u need, the source code and the pictures for better visualization are attached, so i please you to look in that code, its no huge code block, the function paintAll() carries that document.write() call, that causes the rebuild nad/or repaint of that site, so there should be the point to fix i think i will post that function here, but for more overview have the rest, all i got source code inclusive the nice chesspics attached in a .zip file.

thanks anyway for your time 😉

[code=php]function paintAll(){
document.write(“<script src=”ChessGame.js” language=”JavaScript” type=”text/javascript”></script><table width=”100%” heigth=”100%” border=”5″><tr><td align=center>”+paintField()+”</td><td align=center>”+paintHitTable()+”</td></tr></table>n<form name=”input”>nt<p align=center>von “A-H”: <input type=”text” name=”fromCol” size=”3″ maxlength=”1″>nt von “1-8″: <input type=”text” name=”fromRow” size=”3″ maxlength=”1″><p>nt<p align=center>nach “A-H”: <input type=”text” name=”toCol” size=”3″ maxlength=”1″>nt nach “1-8″: <input type=”text” name=”toRow” size=”3″ maxlength=”1″></p>nt<p align=center><input type=”button” value=”ziehen” onclick=”turn(this.form.fromCol.value,this.form.fromRow.value,this.form.toCol.value,this.form.toRow.value)”><p>n</form>”);
}[/code]

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@knoobauthorOct 04.2007 — sorry, it seams so, that i forgot to attach the source code ? so here it is attached now ...

[upl-file uuid=e19d75ad-f3cd-4181-b380-0c03611aa37d size=19kB]ChessGame.zip[/upl-file]
Copy linkTweet thisAlerts:
@knoobauthorOct 11.2007 — exists there a thread which answers my question?? didnt found any ...

an idea or perhaps another point of view of that problem could be the hint for a solution.
Copy linkTweet thisAlerts:
@knoobauthorOct 27.2007 — hey guys, its just an error with importing, so it shouldn'T be so hard ... but i got no idea how to solute it .... did u have any ideas ?!?!?!
×

Success!

Help @knoob 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.16,
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,
)...