Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 2 of 2
  1. #1
    Junior Member
    Join Date
    Sep 2015
    Posts
    5
    Member #
    51796

    Multiple timers in JS

    I have some home automation I am controlling with JS. I need to wait for the first command to be processed before sending the next.

    So both of these work great:
    Code:
    <button onclick="SendIR(xxx)">
    <button onclick="SendIR(xxx);setTimeout('SendIR(yyy);',500);">
    The problem arises when I try to send more than 2 commands through a button. I think the second timer is stepping on the first timer (I dont even know is JS supports multiple timers).

    So this does not work:
    Code:
    <button onclick="SendIR(xxx);setTimeout('SendIR(yyy);',500);setTimeout('SendIR(zzz);',500);">
    Is there a way to use multiple timers or another way I can have several events happen onclick with a pause between each?

    Thanks

  2.  

  3. #2
    Junior Member
    Join Date
    Sep 2015
    Posts
    1
    Member #
    52070
    Why are you using timers in the first case? Is your function SendIR doing asynchronous stuff?


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 09:01 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com