Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
assistance with setInterval or setTimeout
Old 04-22-2009, 09:19 PM assistance with setInterval or setTimeout
seannarae's Avatar
Skilled Talker

Posts: 65
Location: san francisco, ca
Trades: 0
Client has a form that once posted will load another page containing a confirmation number to the end-user.

The DB side isnt built yet, wont be for some time maybe, and wont be by me.
Client states that in the worst case, it might be "8-10 seconds" before the DB can load that confirmation page. Thus, he wants feeback for the user regarding 'please wait' and a spinning graphic (indeterminate progress meter)

i've decided to prototype the delay for the client, showing him not only the spinning please wait graphic, but an 8-10 second delay in loading the confirmation page.

For the spinner, i have an onclick event on the submit button, swapping classes on a DIV containing the graphic (display:none > display:block).

so now it seems all i need to do to complete the prototype is to delay the other onclick event on that button, which is to load the confirmation page.

Here is a sample of what is NOT working. This does not include the code with swap classes. I want to get the delay/interval working first.

I could put the URL to go to up in my function. But was trying to nest it all in my onclick event.

IN THE HEAD
Code:
<SCRIPT LANGUAGE="JavaScript">
function PleaseWait()
{
  setTimeout("PleaseWait()", 8000);
}
</SCRIPT>


IN THE HTML

Code:
<button name="Submit" onclick="PleaseWait('parent.location='http://www.google.com')">Submit</button>
seannarae is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-23-2009, 05:10 PM Re: assistance with setInterval or setTimeout
seannarae's Avatar
Skilled Talker

Posts: 65
Location: san francisco, ca
Trades: 0
SOLUTION FOUND. THANKS FOR READING.

While i lack the proper js chops and there will massacre the terminology, here's what i found to work in my prototype.

I needed to apply the setTimeout function to another function, in this case, what i am calling "confirmation". This waits the specified amount of time before it calls the function.

Then, i simply needed to do more research & testing. I needed to tell the function what to do, or, where to go using js location object.

IN THE HEAD:
Code:
<script language=javascript>
function pleaseWait(){
setTimeout("confirmation()",8000);
}

function confirmation(){
location.href="http://www.google.com"
}
</script>

IN THE BODY:
Code:
<button name="Submit" onclick="P7_MultiClass2('please_wait','divON','full_wrap','divoff');pleaseWait()" >Submit</button>
Just needed to sleep on it, then attack it again with a fresh head. Thanks again.
seannarae is offline
Reply With Quote
View Public Profile
 
Old 04-23-2009, 06:03 PM Re: assistance with setInterval or setTimeout
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Quote:
Just needed to sleep on it, then attack it again with a fresh head. Thanks again.
:-)
That eternal problem, sitting between the keyboard and the chair...
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to assistance with setInterval or setTimeout
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11698 seconds with 12 queries