Avatar billede coders Nybegynder
16. marts 2003 - 10:23 Der er 8 kommentarer og
1 løsning

ska ha hjælp til counter

hej jeg skal bruge en counter ligesom den her på www.manutd.com altså en der tæller ned til en begivenhed.

nogen der kan hjælpe.......
Avatar billede jakobclausen Nybegynder
16. marts 2003 - 10:29 #1
Du kan bruge dette script:
<html>
<body>

<script language="JavaScript1.2">

/*
Dynamic countdown Script- © Dynamic Drive (www.dynamicdrive.com)
For full source code, 100's more DHTML scripts, and TOS,
visit http://www.dynamicdrive.com
*/


function setcountdown(themonth,theday){
mo=themonth;da=theday;
curDate = new Date();
theDate = new Date(themonth + "-" + theday + "-" + curDate.getYear());
if (curDate >= theDate)
yr = curDate.getYear() + 1;
else
yr= curDate.getYear();
}

//////////CONFIGURE THE COUNTDOWN SCRIPT HERE//////////////////

//STEP 1: Configure the countdown-to date, in the format year, month, day:
setcountdown(5,25)

//STEP 2: Change the two text below to reflect the occasion, and message to display on that occasion, respectively
var occasion="Christmas!"
var message_on_occasion="Merry Christmas!"

//STEP 3: Configure the below 5 variables to set the width, height, background color, and text style of the countdown area
var countdownwidth='480px'
var countdownheight='20px'
var countdownbgcolor='lightblue'
var opentags='<font face="Verdana"><small>'
var closetags='</small></font>'

//////////DO NOT EDIT PASS THIS LINE//////////////////

var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
var crosscount=''

function start_countdown(){
if (document.layers)
document.countdownnsmain.visibility="show"
else if (document.all||document.getElementById)
crosscount=document.getElementById&&!document.all?document.getElementById("countdownie") : countdownie
countdown()
}

if (document.all||document.getElementById)
document.write('<span id="countdownie" style="width:'+countdownwidth+'; background-color:'+countdownbgcolor+'"></span>')

window.onload=start_countdown


function countdown(){
var today=new Date()
var todayy=today.getYear()
if (todayy < 1000)
todayy+=1900
var todaym=today.getMonth()
var todayd=today.getDate()
var todayh=today.getHours()
var todaymin=today.getMinutes()
var todaysec=today.getSeconds()
var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
futurestring=montharray[mo-1]+" "+da+", "+yr
dd=Date.parse(futurestring)-Date.parse(todaystring)
dday=Math.floor(dd/(60*60*1000*24)*1)
dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)
//if on day of occasion
if(dday<=0&&dhour<=0&&dmin<=0&&dsec<=1&&todayd==da){
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+message_on_occasion+closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+message_on_occasion+closetags
return
}
//if passed day of occasion
else if (dday<=-1){
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+"Occasion already passed! "+closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+"Occasion already passed! "+closetags
return
}
//else, if not yet
else{
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds left until "+occasion+closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds left until "+occasion+closetags
}
setTimeout("countdown()",1000)
}
</script>

<ilayer id="countdownnsmain" width=&{countdownwidth}; height=&{countdownheight}; bgColor=&{countdownbgcolor}; visibility=hide><layer id="countdownnssub" width=&{countdownwidth}; height=&{countdownheight}; left=0 top=0></layer></ilayer>

</body>
</html>
Avatar billede snortop Nybegynder
16. marts 2003 - 10:32 #3
Jeg kan også godt selv lide denne.. som tæler ned til en dag + tidspunktet som jeg havde brug for på det tidspunkt.

Et script jeg har fundet på nettet. Husker ikke lige hvor!
<Body OnLoad="java script:countdown();">
<SCRIPT>
<!-- hide script
//change your event date event here.
var eventdate = new Date("Mar 24, 2003 16:30:00 GMT");

function toSt(n) {
  s=""
  if(n<10) s+="0"
  return s+n.toString();
}

function countdown() {
  cl=document.clock;
  d=new Date();
  count=Math.floor((eventdate.getTime()-d.getTime())/1000);
  if(count<=0) {
    cl.days.value ="MIL";
    cl.hours.value="LE";
    cl.mins.value="NI";
    cl.secs.value="UM";
    alert("The Goal is Meet"); // Message which appears when time is out
    return;
  }
  cl.secs.value=toSt(count%60);
  count=Math.floor(count/60);
  cl.mins.value=toSt(count%60);
  count=Math.floor(count/60);
  cl.hours.value=toSt(count%24);
  count=Math.floor(count/24);
  cl.days.value=count;
  setTimeout("countdown()",500);
}
// end script -->
</SCRIPT>
<center>
<FORM name="clock"></P>
<TABLE BORDER=5 CELLSPACING=5 CELLPADDING=0 BGCOLOR="#000000">
<TR>
<TD ALIGN=CENTER WIDTH="31%" BGCOLOR="#000080"><FONT COLOR="#00FF00"><B>Days:</B></FONT></TD>
<TD ALIGN=CENTER WIDTH="23%" BGCOLOR="#000080"><FONT COLOR="#00FF00"><B>Hours:</B></FONT></TD>
<TD ALIGN=CENTER WIDTH="23%" BGCOLOR="#000080"><FONT COLOR="#00FF00"><B>Mins:</B></FONT></TD>
<TD ALIGN=CENTER WIDTH="23%" BGCOLOR="#000080"><FONT COLOR="#00FF00"><B>Secs:</B></FONT></TD>
</TR>
<TR>
<TD ALIGN=CENTER><INPUT name="days" size=4></TD>
<TD ALIGN=CENTER><INPUT name="hours" size=2></TD>
<TD ALIGN=CENTER><INPUT name="mins" size=2 ></TD>
<TD ALIGN=CENTER><INPUT name="secs" size=2 ></TD>
</TR>
<TR>
<TD COLSPAN="4" BGCOLOR="#000080">
<center><FONT SIZE=+2 COLOR="#00FF00">Undtil meeting!</FONT></center>
</TD>
</TR>
</TABLE>
</FORM>
</center>

</body>
Avatar billede snortop Nybegynder
16. marts 2003 - 10:34 #4
mit eksempel er også til at se her
http://www25.brinkster.com/lordrebus/countdown.asp
Avatar billede jakobclausen Nybegynder
16. marts 2003 - 10:36 #5
Avatar billede coders Nybegynder
16. marts 2003 - 11:16 #6
snortop kan man ikke lave tekst i stedetfor inputs ???
Avatar billede snortop Nybegynder
16. marts 2003 - 12:37 #7
Jo det kan man vel ... det jo bare navn der bliver henvist til.. nu var scriptet jeg fandt bare med input!
Avatar billede coders Nybegynder
19. marts 2003 - 09:43 #8
jeg skal bruge en som kan hjælpe med at lave en counter i stil med den på manutd.com som selv skifter nedtælling til næste kamp automatisk.

Man skal kunne styre det via database eller text fil...
Avatar billede coders Nybegynder
28. maj 2004 - 21:29 #9
lukker...
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester