"Torben Grover Eriksen" <torben@grover.dk> wrote in message
news:451fe9a2$0$75028$14726298@news.sunsite.dk...
> Jeg har brugt det script her på siden, "nedtælling til et bestemt
> tidspunkt"
http://www.html.dk/scripts/javascript/00026/
> Nu vil jeg gerne bruge et som tæller fremad fra en bestemt dato,
> men jeg er ikke nogen ørn til Javascript, så jeg tænkte på om der
> var en venlig sjæl der havde lavet et sådan og jeg så kunne få
> lov at bruge det.
> MVH Torben
>
> --
> Vil du lære at kode HTML, XHTML, CSS, SSI, ASP eller ASP.NET?
> - Pædagogiske tutorials på dansk
> - Kom godt i gang med koderne
> KLIK HER! =>
http://www.html.dk/tutorials
Indsættes i head:
<SCRIPT LANGUAGE="JavaScript">
<!--
/* Initializations */
var timerID;
var timerRunning = false;
var today = new Date();
var startday = new Date();
var secPerDay = 0;
var minPerDay = 0;
var hourPerDay = 0;
var secsLeft = 0;
var secsRound = 0;
var secsRemain = 0;
var minLeft = 0;
var minRound = 0;
var minRemain = 0;
var timeRemain = 0;
/* This function will stop the clock */
function stopclock()
{
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
/* This function will start the clock */
function startclock()
{
stopclock();
showtime1();
}
/* This function will display the count-up */
function showtime1()
{
startday = new Date("July 20, 1969 16:18 EDT");
startday.setYear("1969");
today = new Date();
secsPerDay = 1000 ;
minPerDay = 60 * 1000 ;
hoursPerDay = 60 * 60 * 1000;
PerDay = 24 * 60 * 60 * 1000;
/* Seconds */
secsLeft = (today.getTime() - startday.getTime()) / minPerDay;
secsRound = Math.round(secsLeft);
secsRemain = secsLeft - secsRound;
secsRemain = (secsRemain < 0) ? secsRemain = 60 - ((secsRound - secsLeft) *
60) : secsRemain = (secsLeft - secsRound) * 60;
secsRemain = Math.round(secsRemain);
/* Minutes */
minLeft = ((today.getTime() - startday.getTime()) / hoursPerDay);
minRound = Math.round(minLeft);
minRemain = minLeft - minRound;
minRemain = (minRemain < 0) ? minRemain = 60 - ((minRound - minLeft) * 60)
: minRemain = ((minLeft - minRound) * 60);
minRemain = Math.round(minRemain - 0.495);
/* Hours */
hoursLeft = ((today.getTime() - startday.getTime()) / PerDay);
hoursRound = Math.round(hoursLeft);
hoursRemain = hoursLeft - hoursRound;
hoursRemain = (hoursRemain < 0) ? hoursRemain = 24 - ((hoursRound -
hoursLeft) * 24) : hoursRemain = ((hoursLeft - hoursRound) * 24);
hoursRemain = Math.round(hoursRemain - 0.5);
/* Days */
daysLeft = ((today.getTime() - startday.getTime()) / PerDay);
daysLeft = (daysLeft - 0.5);
daysRound = Math.round(daysLeft);
daysRemain = daysRound;
/* Time */
if (daysRemain == 1)
{
day_rem = " day, "
}
else
{
day_rem = " days, "
}
if (hoursRemain == 1)
{
hour_rem = " hour, "
}
else
{
hour_rem = " hours, "
}
if (minRemain == 1)
{
min_rem = " minute, "
}
else
{
min_rem = " minutes, "
}
if (secsRemain == 1)
{
sec_rem = " second"
}
else
{
sec_rem = " seconds"
}
timeRemain = daysRemain + day_rem + hoursRemain + hour_rem + minRemain +
min_rem + secsRemain + sec_rem;
document.up.face.value = timeRemain;
timerID = setTimeout("showtime1()",1000);
timerRunning = true;
}
//-->
</SCRIPT>
<BODY onLoad="startclock()">
I body:
<FORM NAME="up">
<INPUT TYPE="text" NAME="face" SIZE="47" VALUE="A browser supporting
JavaScript 1.1+ is needed.">
</FORM>
Er sikker på du kan finde stedet hvor startdatoen skal rettes!
Håber du kan bruge det...
/Thrane