PHP and Javascript seconds problem

by 5 replies
6
I have the above code, the timer is working fine. When the timeleft is 0 i want to refresh the page and ,but the problem is that the page is refreshing 10 - 20 times after finishing. Thanks for any help !
#programming #javascript #php #problem #seconds
  • Is that a mis-named variable? Should trainleft be timeleft? I see no other mention or use of trainleft in this code.

    Also...

    Seems to suggest that a "find and replace" command went awry at some point.

    -Ryan
  • My code is more longer , and I have replaced some variables to make the code more clear for the forum readers......
  • Javascript created by PHP. Not sure that's the best way to do this.

    Anyways...

    ...having glanced at it, I think it may be because there is nothing to tell it to stop doing what it's doing when the decrementing counter reaches zero and continues down through negative numbers.

    Cheers,

    Neil
  • if(timeleft < 0) {
    window.location = \"index.php\"
    }
    here is the code
  • I have solved the problem , when the timer is ended the page is not refreshed ,it submits a form via Javascript with a given value

Next Topics on Trending Feed