Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-16-2012, 10:08 PM   PM User | #1
maraudir
New to the CF scene

 
Join Date: Nov 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
maraudir is an unknown quantity at this point
setTimeout issues

I have an Adobe LiveCycle document with some javascript in it. My main issue is with a countdown timer I am trying to use. I had no luck with setInterval and limited success with setTimeout.
Code:
function TimedOut() {
	app.alert ("The time has elapsed");
	//cancel the timer
	app.clearInterval(timeout);
}
//prompt for number of seconds
var secondCount = app.response("Enter number of seconds", "Number of Seconds", "", "")
//start counter
if (secondCount >= 0)
//timer set for thousandths of a second
var timeout = app.setTimeOut("xfa.form.gameform.money_game.start_time.TimedOut()", (1000*secondCount));
Any help would be appreciated. I can only get the above code to work on 6 seconds or less.
maraudir is offline   Reply With Quote
Old 11-17-2012, 02:07 PM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,033
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
You should avoid giving names or id's to your variables/functions/arguments/forms words which are HTML/JavaScript methods/properties/attributes such as 'name' or 'id' or 'value' or 'test' or 'text' or 'checked' or 'click' or 'href' or 'closed' or 'go' or 'submit' or 'replace' or 'button' or 'radio' or 'parseInt'. Or 'timeout'.

I don't use Adobe but this works just fine in vanilla Javascript:-

Code:
<script type = "text/javascript">

function TimedOut() {
alert ("The time has elapsed");
}

//prompt for number of seconds

var secondCount = Number(window.prompt("Enter number of seconds", "Number of Seconds")) || 0;  // trap NaN entries
//start counter
if (secondCount >= 0) {
//timer set for thousandths of a second
window.setTimeout(TimedOut, 1000*secondCount);
}

</script>
__________________

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.
Philip M is offline   Reply With Quote
Old 11-17-2012, 07:23 PM   PM User | #3
maraudir
New to the CF scene

 
Join Date: Nov 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
maraudir is an unknown quantity at this point
No dice.
Even trying those changes, I can't get it to work at all that way. I'll have to tinker around some more then.

Last edited by maraudir; 11-18-2012 at 09:20 AM..
maraudir is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:21 AM.


Advertisement
Log in to turn off these ads.