...

View Full Version : setTimeout issues



maraudir
11-16-2012, 11:08 PM
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.

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.

Philip M
11-17-2012, 03:07 PM
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:-


<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>

maraudir
11-17-2012, 08:23 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum