/    Sign up×
Community /Pin to ProfileBookmark

Countdown Timer

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[/url], and one of the functions we had on the old site is no longer working and I cannot figure it out nor can the guy who redesigned the site, or atleast not yet. Anyway, each song is listed in the database with a duration along with alot of other information. So this is the code that we had in the old site and it worked like a charm.
//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:&nbsp;<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.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@justinbarneskinJul 29.2009 — Is there a PHP forum? All that looks familiar but without a server to call my own, I can't get interested.
Copy linkTweet thisAlerts:
@dk96mauthorJul 29.2009 — There is a php forum, but I think this is a javascript issue. The php works fine. LIke I said I can get the secs remaining, but the javascript is suppose to take that convert to mm:ss then show the countdown. Can anyone help please
×

Success!

Help @dk96m spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...