...

View Full Version : Help combining....



gregm65
01-01-2008, 04: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&#37;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.

vwphillips
01-01-2008, 04:50 PM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<title></title>
<script type="text/javascript">
var baseDate = "2005 September 30 09:05";
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 frm=document.clock;
frm.years.value= nYears;
frm.months.value= nMonths;
frm.days.value= rDays;
frm.hours.value= nHours;
frm.mins.value= nMin;
frm.secs.value= nSec;
setTimeout("dispCounter()",1000)
}

window.onload=dispCounter;
</script></head>

<body>
</font>
<div id="elapsed" style="height: 92px;">since Stempy passed away, yet there has been NO JUSTICE for his preventable death.</div>
<form name="clock">
<table border=3>

<tr>
<td>Years:</td>
<td>Months:</td>
<td>Days:</td>
<td>Hours:</td>
<td>Mins:</td>
<td>Secs:</td>
</tr>


<tr>
<td><input name="years" size="4"></td>
<td><input name="months" size="4"></td>
<td><input name="days" size="4"></td>
<td><input name="hours" size="4"></td>
<td><input name="mins" size="4"></td>
<td><input name="secs" size="4"></td>
</tr>
</table></form>
</body>

</html>

gregm65
01-02-2008, 01:52 AM
Thank you, Vic! I certainly do appreciate it! See the end result here:

http://stempy.bravehost.com/

Greg.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum