Without the markup (HTML) that goes with this code it's hard to tell. I set up a simple demo with all of the referenced elements (most likely not in the way they were intended, but just to see if the code did anything) and it sort of worked. There seems to be a superfluous function that does nothing in particular and that's not referenced by, nor references anything else in the other code nor elements referenced by the other code (checkTime) and another that needs input to do anything (countdown(yr,m,d,hr,min)), the latter requiring markup that it references as well as said input to do anything. Have you actually tried using any of this code? In any case here is a sort of working demo:
Code:
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div id="count2"></div>
<div id="dhour"></div>
<div id="dmin"></div>
<div id="dsec"></div>
<div id="hours"></div>
<div id="minutes"></div>
<div id="seconds"></div>
<div id="spacer1"></div>
<div id="spacer2"></div>
<script type="text/javascript">
// JavaScript Document
var current="End!!"; //-->enter what you want the script to display when the target date and time are reached, limit to 20 characters
var year=2016; //-->Enter the count down target date YEAR
var month=03; //-->Enter the count down target date MONTH
var day=26; //-->Enter the count down target date DAY
var hour=10; //-->Enter the count down target date HOUR (24 hour clock)
var minute=00; //-->Enter the count down target date MINUTE
var tz=+1; //-->Offset for your timezone in hours from UTC (see http://wwp.greenwichmeantime.com/index.htm to find the timezone offset for your location)
//--> DO NOT CHANGE THE CODE BELOW! <--
var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
function checkTime(i)
{
if (i<10)
{
i="0" + i;
}
return i;
}
function countdown(yr,m,d,hr,min){
theyear=yr;themonth=m;theday=d;thehour=hr;theminute=min;
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 todaystring1=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec;
var todaystring=Date.parse(todaystring1)+(tz*1000*60*60);
var futurestring1=(montharray[m-1]+" "+d+", "+yr+" "+hr+":"+min);
var futurestring=Date.parse(futurestring1)-(today.getTimezoneOffset()*(1000*60));
var dd=futurestring-todaystring;
var dday=Math.floor(dd/(60*60*1000*24)*1);
var dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1) + (dday*24);
var dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1);
var dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1);
if(dday<=0&&dhour<=0&&dmin<=0&&dsec<=0){
document.getElementById('count2').innerHTML=current;
document.getElementById('count2').style.display="inline";
document.getElementById('count2').style.width="390px";
document.getElementById('dhour').style.display="none";
document.getElementById('dmin').style.display="none";
document.getElementById('dsec').style.display="none";
document.getElementById('hours').style.display="none";
document.getElementById('minutes').style.display="none";
document.getElementById('seconds').style.display="none";
document.getElementById('spacer1').style.display="none";
document.getElementById('spacer2').style.display="none";
return;
}
else {
document.getElementById('count2').style.display="none";
document.getElementById('dhour').innerHTML=dhour;
document.getElementById('dmin').innerHTML=dmin;
document.getElementById('dsec').innerHTML=dsec;
setTimeout("countdown(theyear,themonth,theday,thehour,theminute)",1000);
}
}
countdown(2016,5,6,10,23)
</script>
</body>
</html>
Now, if you're quick/lucky/whatever, that might do it for you. But likely you will have more questions, feel free to ask. Please include any additional code/information that might make it clearer as to what you are trying/doing.
You may also want to have a look at this thread:
http://www.dynamicdrive.com/forums/s...ipt-Auto-start
Bookmarks