CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   JavaScript programming (http://www.codingforums.com/forumdisplay.php?f=2)
-   -   setTimeout issues (http://www.codingforums.com/showthread.php?t=282405)

maraudir 11-16-2012 10:08 PM

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.

Philip M 11-17-2012 02: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:-

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>


maraudir 11-17-2012 07: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.


All times are GMT +1. The time now is 03:35 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.