View Full Version : A text Game... Javascript Submit...

12-23-2005, 07:18 PM
I've been working on a new javascript game for a while now. At the end of the game I've been trying to get my javascript to submit information to a php script, which, in turn, writes that highscores data to a file. I need the script to be executed once the last image on the final page loads. SO... I was wondering two things.

1) How do I get a javascript to autosubmit two simple variables to a php script.
2) How do I place that javascript in my image tag?

<img src=congratulations.jpg onload='javascript: var1=time; var2=name;

I'm totally lost after this...

Any help?

Philip M
12-24-2005, 09:34 AM
First of all, the data to be submitted must be within a form.

<FORM name ="MyForm" action = ...............>

The submission of the form can only be triggered by an event handler such as onBlur, onClick, onmouseOver and so on. Also onLoad - the load event does not occur until all the elements on the HTLM web page have been loaded so the onLoad event handler will only run after all elements are present on a page.

But you cannot attach the onLoad event handler to an image in the way you are trying to do.

Also remember that a further (second) onLoad event handler assigned in the <BODY> tag will overwrite one in a script. In other words, you can only have one onLoad event handler.

Hope this helps.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum