/    Sign up×
Community /Pin to ProfileBookmark

Simple ‘please wait …’ message

Hi,

I’ve been trying to get a really simple ‘please wait…’ message to work on an onclick event, before submitting a form. I’ve seen some people do the same thing with a ‘preload’ message (ie when the new page loads, not when the old page exits), but that does not work for me, as the delay happens while my server side database searches, not as the page actually loads in the browser.

Here is my attempt at a solution. It does not work, and all that happens is that the form is submitted.
In JavaScript Include file:

[CODE]function submitNow()
{
document.getElementById(“mainbody”).style.visibility = “hidden”;
document.getElementById(“waiting”).style.visibility = “visible”;
document.getElementById(“waiting”).value = “Please wait …”;
window.setTimeout(‘letsGo()’, 500);
}
function letsGo()
{
document.forms[0].submit();
}[/CODE]

In body:

[CODE]<div id=”waiting” style=”z-index:9999999;visibility:hidden;”></div>
<div id=”mainbody”>A whole load of stuff including
<form> …
<img src=”icons.png” name=”srch1″ alt=”Search” onmouseover=”somefunction()” onclick=”submitNow()” style=”cursor: pointer;”/>
</form>
</div>
[/CODE]

Seems extremely simple. So why doesn’t it work? I’ll freely admit my JavaScript sucks … so be gentle.

Many thanks for your thoughts,

BMA

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@slaughtersJun 26.2007 — I think that this:

[I]document.getElementById("waiting").[B]value [/B]= "Please wait ...";[/I]

is the problem.

For DIV's you need to use the "innerHTML" assignment

(or use the DOM to assign a value to the node - much less straight forward than innerHTML)
Copy linkTweet thisAlerts:
@benmoreassyntauthorJun 26.2007 — Thanks for pointing out that error. I found another one, and together it's fixed.

Much appreciated

BMA
×

Success!

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