Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2014-09-30 06:54:28
- alivato
- Member
- Registered: 2011-03-31
- Posts: 151
Timer does not work
Why this code does not work?
Page
<txp:output_form form="timer" />
Form timer
<div class="topbox">
<div id="ny_date"></div>
</div>
Other form with code
<script LANGUAGE="javascript">
function tNY()
{
var today = new Date();
var BigDay = new Date("January 01, 2015");
var timeLeft = (BigDay.getTime() - today.getTime());
var e_daysLeft = timeLeft / 86400000;
var daysLeft = Math.floor(e_daysLeft);
var e_hrsLeft = (e_daysLeft - daysLeft)*24;
var hrsLeft = Math.floor(e_hrsLeft);
var e_minsLeft = (e_hrsLeft - hrsLeft)*60;
var minsLeft = Math.floor(e_minsLeft);
var seksLeft = Math.floor((e_minsLeft - minsLeft)*60);
if (BigDay.getTime() > today.getTime() )
document.getElementById("ny_date").innerHTML = '<div class="bnyy">Left until the New Year<br /></div> <div class="bny"><b>'+daysLeft+'</b> days<b>'+hrsLeft+'</b> h. <b>'+minsLeft+'</b> min. <b>'+seksLeft+'</b> sec.</div>'
else
document.getElementById("ny_date").innerHTML = '<div class="nyy">Congr...</div> <div class="ny">NY!!!</div>'
}
setInterval("tNY()", 50)
</script>
Last edited by alivato (2014-09-30 06:55:48)
Offline
Re: Timer does not work
Hi alivato,
There is a countdown plugin which works seamlessly and it might be of help
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: Timer does not work
colak wrote #284329:
There is a countdown plugin
Umm, do you mean smd_countdown ? Regardless, in this instance it might not be the best solution, although you can use it to seed a Javascript timer, you still need to actually write the Javascript bit, which is what the problem is here.
alavito, in what way does the code not work? Any errors in the browser’s debug console?
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: Timer does not work
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Pages: 1