I am not sure I have the right forum or subforum, but I am looking for a little help. I do not know ajax or javascript or php very well. I run an internet radio station that runs off a broadcasting program and a mysql database. We recently updated out site, [url]www.wdmbradio.com
//This will give us the seconds remaining for the song, based on the start //time, duration and current server time.
$starttime = strtotime($song[“date_played”]);
$curtime = time();
$secsRemain = (round($song[“duration”] / 1000)-($curtime-$starttime));
//This is the javascript that we had to i guess convert it to mm:ss. What //this did on the old site was when the timer reached zero it would refresh //the entire site. Now we have each section by itself using AJAX i believe //and this code will no longer work.
<script language=”JavaScript”>
var countDownInterval = <? echo $secsRemain; ?>;
var countDownTime = countDownInterval + 1;
if (document.all||document.getElementById)
countDown();
else
window.onload = countDown;
function countDown() {
countDownTime–;
if (countDownTime == 0) {
countDownTime = countDownInterval;
window.location.reload();
return;
}
else if (countDownTime < 0)
countDownTime = 30;
if (document.all)
document.all.countDownText.innerText = secsToMins(countDownTime);
else if (document.getElementById)
document.getElementById(“countDownText”).innerHTML = secsToMins(countDownTime);
counter = setTimeout(“countDown()”, 1000);
}
function secsToMins(theValue) {
var theMin = Math.floor(theValue / 60);
var theSec = (theValue % 60);
if (theSec < 10)
theSec = “0” + theSec;
return(theMin + “:” + theSec);
}
</script>
//This is the code we had to display the time left in mm:ss
<b>Currently Playing</b> (Time left: <b id=”countDownText”></b>)
All this stuff use to be in one file called playing.php. Now we have it broken down to current song, recent song, coming up, etc. So when I try to put this code in the now playing section where I want it, it doesnt work. I can echo the secsremaining and that shows up, and the value changes when the now playing refreshes. Can anyone help me figure this out. I am so lost.