Enjoy an ad free experience by logging in. Not a member yet?
Register .
01-14-2013, 06:09 AM
PM User |
#1
Regular Coder
Join Date: Oct 2002
Location: Sydney, Australia
Posts: 771
Thanks: 40
Thanked 5 Times in 4 Posts
set timeout problem
Is there a reason why this doesn't work?
Code:
function delay(){
soundManager.play('piano','../../media/mp3/piano.mp3');
setTimeout('function(){document.getElementById("tutor").submit();}',4000);
}
...but this does:
Code:
function delay1(){
soundManager.play('piano','../../media/mp3/piano.mp3');
setTimeout('delay2()',4000);
}
function delay2(){
document.getElementById("tutor").submit();
}
It seems to me that the first one should work too.
__________________
The difference between genius and stupidity is that genius has its limits. (Albert Einstein)
01-14-2013, 07:17 AM
PM User |
#2
Supreme Master coder!
Join Date: Jun 2002
Location: London, England
Posts: 17,044
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Suggest you check the position of the closing brace.
We've clearly still got players coming into the squad who haven't arrived yet. - London Irish RFC Coach
__________________
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
01-14-2013, 07:28 AM
PM User |
#3
Regular Coder
Join Date: Oct 2002
Location: Sydney, Australia
Posts: 771
Thanks: 40
Thanked 5 Times in 4 Posts
It seems right to me. All I am doing is cutting and pasting this:
Code:
function delay2(){
document.getElementById("tutor").submit();
}
(without the function name) into this:
Code:
function delay(){
soundManager.play('piano','../../media/mp3/piano.mp3');
setTimeout('FUNCTION GOES HERE ',4000);
}
Maybe I've stared at it too long!
__________________
The difference between genius and stupidity is that genius has its limits. (Albert Einstein)
01-14-2013, 07:43 AM
PM User |
#4
Supreme Master coder!
Join Date: Jun 2002
Location: London, England
Posts: 17,044
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
setTimeout('function(){document.getElementById("tutor").submit(),4000}');
__________________
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Last edited by Philip M; 01-14-2013 at 07:49 AM ..
01-14-2013, 08:16 AM
PM User |
#5
Regular Coder
Join Date: Oct 2002
Location: Sydney, Australia
Posts: 771
Thanks: 40
Thanked 5 Times in 4 Posts
That's confusing Philip because it doesn't work either!
...and it doesn't look like the setTimeout pattern.
Strange. Maybe you can't put a document.getElementById() inside a setTimeout.
__________________
The difference between genius and stupidity is that genius has its limits. (Albert Einstein)
01-14-2013, 10:23 AM
PM User |
#6
Regular Coder
Join Date: Sep 2010
Location: London
Posts: 961
Thanks: 0
Thanked 198 Times in 193 Posts
setTimeout( 'document.getElementById("tutor").submit()', 4000 );
but preferably
setTimeout( function(){ document.getElementById( "tutor" ).submit(); }, 4000 );
Users who have thanked Logic Ali for this post:
01-14-2013, 10:24 AM
PM User |
#7
Supreme Master coder!
Join Date: Jun 2002
Location: London, England
Posts: 17,044
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Quote:
Originally Posted by
tpeck
That's confusing Philip because it doesn't work either!
...and it doesn't look like the setTimeout pattern.
Strange. Maybe you can't put a document.getElementById() inside a setTimeout.
Is the document.getElementById("tutor") the id of a form?
__________________
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
01-14-2013, 11:06 AM
PM User |
#8
Regular Coder
Join Date: Oct 2002
Location: Sydney, Australia
Posts: 771
Thanks: 40
Thanked 5 Times in 4 Posts
Thanks Logic Ali, those work well.
Yes, it is the id of a form. Here is the whole thing:
Code:
function delay(value){
soundManager.play('piano','../../media/mp3/piano.mp3');
setTimeout(function(){document.getElementById(value).submit();},4000);
}
<form id="tutor" method="post" target="_self" action="feedback(tutor).html">
<input type="submit" onclick="delay('tutor');return false" class="TextArea" value="CLICK HERE">
</form>
<form id="student" method="post" target="_self" action="feedback(student).html">
<input type="submit" onclick="delay('student');return false" class="TextArea" value="CLICK HERE">
</form>
It may be useful for someone else that wants to play a sound before submitting or, for some other reason, not immediately submit.
__________________
The difference between genius and stupidity is that genius has its limits. (Albert Einstein)
Jump To Top of Thread
Thread Tools
Rate This Thread
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
All times are GMT +1. The time now is 01:10 AM .
Advertisement
Log in to turn off these ads.