Jump to content

Run a PHP Script at the end of a timer?


ronnie88

Recommended Posts

How would I run a php file at the end of a javascript timer...the timer I am using is below:

<script type="text/javascript">

var alertTimerId = 0;

function alertTimerClickHandler ( )
{
  if ( document.getElementById("alertTimerButton").value == "Click me and wait 30 min" )
  {
    // Start the timer
    document.getElementById("alertTimerButton").value = "Click me to stop the timer!";
    alertTimerId = setTimeout ( "showAlert()", 1800000 );
  }
  else
  {
    document.getElementById("alertTimerButton").value = "Click me and wait!";
    clearTimeout ( alertTimerId );
  }
}

function showAlert ( )
{
  alert ( "Congratz Your Flight Has Finished! You Received $600!" );
  document.getElementById("alertTimerButton").value = "Click me and wait!";
}

</script>

thank you in advance!

Link to comment
https://forums.phpfreaks.com/topic/116152-run-a-php-script-at-the-end-of-a-timer/
Share on other sites

okay not on another page but it would have to be a script in the same file so they can't go directly to the file and receive the cash... and sorry about the double post wouldn't let me edit the previous post. it would be a simple mysql query update. Thanks again

well if it is that you want to do the update without the page reloading you should read up on some ajax tutorials. try out some stuff and see what it does. the easiest way is to use javascript frameworks such as jquery prototype or dojo etc. but the basics described here where I originally learned it from 2 years ago would work.

 

http://www.w3schools.com/Ajax/Default.Asp

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.