/    Sign up×
Community /Pin to ProfileBookmark

Hiding a form on submit

I am currently coding a game. I am wanting to cut down server load by hiding a form for a certain amount of time every time the page loads.

Explaination:

On the game page you click on a compass (my form) to move your character. The php script moves the character and loads the new page. What I want to happen is when the new page loads to hide the compass for a certain amount of time (3 seconds). This is to keep players from clicking the form 5 times really fast and moving that amount of spaces loading the page once. I figured this would be a javascript situation and my javascript understanding is not very high. Can anyone help?

Here is the code for my form.

[CODE]<p><div id=”compass”><form action=”index.php?do=move” method=”post”>
<center>
<input name=”north” type=”image” src=”images/north.gif” value=”North” />
<input name=”west” type=”image” src=”images/west.gif” value=”West” /><input name=”east” type=”image” src=”images/east.gif” value=”East” /><br />
<input name=”south” type=”image” src=”images/south.gif” value=”South” />
<br /><span class=”style3″>Click on compass to move</span>
</center>
</form></div></p>[/CODE]

If you need more info please let me know and I will post it ASAP!

Thanks

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@FangMay 26.2007 — window.onload=function() {
var obj=document.getElementById('compass');
obj.style.display='none';
window.setTimeout(function(){obj.style.display='block';},3000);
}
Copy linkTweet thisAlerts:
@ProxximoauthorMay 26.2007 — Fang Thank you so very much!!!!

I have one more question. Is there any way that I can put some text in place of the compass to tell the user "Compass reloading to save bandwidth" or something like that while it is hidden. If not then the help given will do just fine!!!! ?

Thanks again!

Proxximo
Copy linkTweet thisAlerts:
@FangMay 26.2007 — window.onload=function() {
var obj=document.getElementById('compass');
obj.style.display='none';
window.setTimeout(function(){document.getElementById('bandwidthText').style.display='none'; obj.style.display='block';},3000);
}

&lt;p&gt;&lt;div id="bandwidthText" style="text-align:center;"&gt;Compass reloading to save bandwidth&lt;/div&gt;&lt;div id="compass"&gt;&lt;form action="index.php?do=move" method="post"&gt;
&lt;center&gt;
&lt;input name="north" type="image" src="images/north.gif" value="North" /&gt;
&lt;input name="west" type="image" src="images/west.gif" value="West" /&gt;&lt;input name="east" type="image" src="images/east.gif" value="East" /&gt;&lt;br /&gt;
&lt;input name="south" type="image" src="images/south.gif" value="South" /&gt;
&lt;br /&gt;&lt;span class="style3"&gt;Click on compass to move&lt;/span&gt;
&lt;/center&gt;&lt;/div&gt;&lt;/p&gt;
Copy linkTweet thisAlerts:
@ProxximoauthorMay 26.2007 — I cant thank you enough Fang! You rock!
Copy linkTweet thisAlerts:
@n_alexievMay 27.2007 — It is a better choise to play with visibility.

Dont play with display ?

<i>
</i>document.forms[0].onSubmit() = function()
{
this.style.visibility = 'hidden';
}


Something like this ?
Copy linkTweet thisAlerts:
@n_alexievMay 27.2007 — Here it is !

If this is what you need from:

<i>
</i>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
&lt;html&gt;

&lt;head&gt;
&lt;meta http-equiv="content-type" content="text/html; charset=iso-8859-1"&gt;
&lt;meta name="author" content="n_alexiev"&gt;

<i> </i>&lt;title&gt;Form&lt;/title&gt;
<i> </i>&lt;script type="text/javascript"&gt;
<i> </i> function submitForm()
<i> </i> {
<i> </i> var obj = document.forms[0];
<i> </i> obj.style.visibility = 'hidden';
<i> </i> }
<i> </i>&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;form onsubmit="submitForm()" action="index.php?do=move" method="post"&gt;
&lt;input name="north" type="image" src="images/north.gif" value="North" /&gt;
&lt;input name="west" type="image" src="images/west.gif" value="West" /&gt;
&lt;input name="east" type="image" src="images/east.gif" value="East" /&gt;
&lt;input name="south" type="image" src="images/south.gif" value="South" /&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@ProxximoauthorMay 27.2007 — Thanks a bunch!
×

Success!

Help @Proxximo 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.18,
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,
)...