Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,081
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    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.

  • #3
    New to the CF scene
    Join Date
    Nov 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •