gregm65
01-01-2008, 03:28 PM
I am a newbie looking for a little bit of coding help. I have a count up script I'm using on my site. Here is an example of it:
http://stempy.bravehost.com/cu.html
Here is the actual script:
<script type="text/javascript">
var baseDate = "2005 September 30 09:05";
var message = "since Stempy passed away, yet there has been NO JUSTICE for his preventable death."
function dispCounter(){
var refDate = new Date(baseDate);
var currDate = new Date();
var elapsedTime = currDate-refDate;
var nDays = parseInt(elapsedTime/86400000);
var nHours = parseInt((elapsedTime-(nDays*86400000))/3600000);
var nMin = parseInt((elapsedTime-(nDays*86400000)-(nHours*3600000))/60000);
var nSec = currDate.getSeconds();
var nYears = parseInt(nDays/365);
var nMonths = parseInt((nDays-(nYears*365))/30);
var rDays = parseInt((nDays-(nYears*365)-(nMonths*30)));
var cYears = "year";
if (nYears != 1){cYears += "s,"} else {cYears += ","}
cMonths = "month";
if (nMonths != 1){cMonths +="s,"} else {cMonths += ","}
var cDays = "day";
if (rDays != 1){cDays += "s,"} else {cDays += ","}
var cHours = "hour";
if (nHours != 1){cHours += "s,"} else {cHours += ","}
var cMinutes = "minute";
if (nMin != 1){cMinutes += "s,"} else {cMinutes += ","}
var cSeconds = "second";
if (nSec != 1){cSeconds += "s,"} else {cSeconds += ","}
document.getElementById('elapsed').innerHTML = "It's been "+nYears+" "+cYears+" "+nMonths+" "+cMonths+" "+rDays+" "+cDays+" "+nHours+" "+cHours+" "+nMin+" "+cMinutes+" and "+nSec+" "+cSeconds+"<br>"+ message
setTimeout("dispCounter()",1000)
}
window.onload=dispCounter;
</script>
What I am wanting to do is insert this into a chart /table like this example, only it includes an extra box for months:
http://www.jsmadeeasy.com/javascripts/Clocks%20And%20Date/Count%20Up%20From%20Date/index.htm (http://www.jsmadeeasy.com/javascripts/Clocks%20And%20Date/Count%20Up%20From%20Date/index.htm)
I want to use the first script, but would like it diplayed like the second script. Any help would be appreciated.
http://stempy.bravehost.com/cu.html
Here is the actual script:
<script type="text/javascript">
var baseDate = "2005 September 30 09:05";
var message = "since Stempy passed away, yet there has been NO JUSTICE for his preventable death."
function dispCounter(){
var refDate = new Date(baseDate);
var currDate = new Date();
var elapsedTime = currDate-refDate;
var nDays = parseInt(elapsedTime/86400000);
var nHours = parseInt((elapsedTime-(nDays*86400000))/3600000);
var nMin = parseInt((elapsedTime-(nDays*86400000)-(nHours*3600000))/60000);
var nSec = currDate.getSeconds();
var nYears = parseInt(nDays/365);
var nMonths = parseInt((nDays-(nYears*365))/30);
var rDays = parseInt((nDays-(nYears*365)-(nMonths*30)));
var cYears = "year";
if (nYears != 1){cYears += "s,"} else {cYears += ","}
cMonths = "month";
if (nMonths != 1){cMonths +="s,"} else {cMonths += ","}
var cDays = "day";
if (rDays != 1){cDays += "s,"} else {cDays += ","}
var cHours = "hour";
if (nHours != 1){cHours += "s,"} else {cHours += ","}
var cMinutes = "minute";
if (nMin != 1){cMinutes += "s,"} else {cMinutes += ","}
var cSeconds = "second";
if (nSec != 1){cSeconds += "s,"} else {cSeconds += ","}
document.getElementById('elapsed').innerHTML = "It's been "+nYears+" "+cYears+" "+nMonths+" "+cMonths+" "+rDays+" "+cDays+" "+nHours+" "+cHours+" "+nMin+" "+cMinutes+" and "+nSec+" "+cSeconds+"<br>"+ message
setTimeout("dispCounter()",1000)
}
window.onload=dispCounter;
</script>
What I am wanting to do is insert this into a chart /table like this example, only it includes an extra box for months:
http://www.jsmadeeasy.com/javascripts/Clocks%20And%20Date/Count%20Up%20From%20Date/index.htm (http://www.jsmadeeasy.com/javascripts/Clocks%20And%20Date/Count%20Up%20From%20Date/index.htm)
I want to use the first script, but would like it diplayed like the second script. Any help would be appreciated.