I am having trouble displaying output from a php script in html for a countdown timer. The times required are input through.
<div id="countdown"> <!-- Display input for the kitchen timer -->
<form method="post" action="display_timer()">
<br>
<br>
<h1>Enter the hours required: <input type="text" name="hours"><br></h1>
<h2>Enter the Minutes required: <input type="text" name="minutes"><br></h2>
<h3>Enter the Seconds required: <input type="text" name="seconds"><br></p>
<br>
<br>
<h4><input type="submit" name="Submit" value="Submit"></h4>
</form>
</div>
Called from a php script with ajax below
function display_timer(){
var myAjax9 = new XMLHttpRequest;
myAjax9.open("GET", "timer.php");
myAjax9.onreadystatechange = function(){
if (myAjax9.readyState == 4 && myAjax7.status == 200){
document.getElementById("timerdisplay").innerHTML = hours+" hours, "+minutes+" minutes, "+seconds+" seconds";
IT=window.setTimeout( "setcountDown()", 10 );
if (hours == '00' && minutes == '00' && seconds == '00') {
seconds = "00";
window.clearTimeout(IT);
window.alert("Time is up. Press OK to continue.");
}
}
}
}
and displayed with
<div id="timerdisplay"> <?php echo "$hoursLeft hours, $minutesLeft minutes, $secondsLeft seconds";?></div> <!-- Display output for the kitchen timer -->
I can put the timer php code on if required.
I am new to php and Ajax so may be doing something hopelessly wrong?