Count Up "timer"
//Dynamic countup Script- ? Dynamic Drive (www.dynamicdrive.com) //For full source code, 100's more DHTML scripts, and TOS, //visit http://www.dynamicdrive.com
function setcountup(theyear,themonth,theday){ yr=theyear;mo=themonth;da=theday }
//////////CONFIGURE THE countup SCRIPT HERE//////////////////
//STEP 1: Configure the date to count up from, in the format year, month, day: //This date should be less than today setcountup(2002,1,29)
//STEP 2: Configure text to be attached to count up var displaymessage="have passed since I was employed! (fulltime)"
//STEP 3: Configure the below 5 variables to set the width, height, background color, and text style of the countup area var countupwidth='95%' var countupheight='20px' //applicable only in NS4 var countupbgcolor='lightblue' var opentags='
' var closetags='
'
//////////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_countup(){ if (document.layers) document.countupnsmain.visibility="show" else if (document.all||document.getElementById) crosscount=document.getElementById&&!document.all?document.getElementById("countupie") : countupie countup() }
if (document.all||document.getElementById) document.write('')
window.onload=start_countup
function countup(){ 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 paststring=montharray[mo-1]+" "+da+", "+yr dd=Date.parse(todaystring)-Date.parse(paststring) 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 (document.layers){ document.countupnsmain.document.countupnssub.document.write(opentags+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds "+displaymessage+closetags) document.countupnsmain.document.countupnssub.document.close() } else if (document.all||document.getElementById) crosscount.innerHTML=opentags+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds "+displaymessage+closetags
//setTimeout("countup()",1000) }
pretty neat huh? (well, I guess not the unemployed part.) To find the script to do that get it here. That site, Dynamic Drive, has some pretty cool other scripts too.
(p.s. Here's a question for the CSS goddesses - how do I add a margin to that layer? I know how to add a margin to a layer specified by a div tag - but this is some sort of weird "ilayer" - me no know css)
update: stopped constant "count" as it seemed to have crashed someones browser. (so the count you see is static, but that is because I commented out a line that refreshes the count).
May 17th, 2002 at 8:45 am
I just did a google search, and it looks like ilayer and layer is a proprietery NN4 thing. But I'm seeing it here on IE6, so that doesn't make sense. Maybe the Javascript above it makes it work. (for reference - scroll down to Layers)
So, the css-goddess's answer? Put
<div style="background-color:lightblue; margin:20px;">around the layer and ilayer tags</div>
and it will ensure you get your margin.
Because ilayer is so odd, I don't think you could guarentee it would work crossbrowser by adding anything else to it, 'specially if the JavaScript is causing it to work with the specs it was. me no know javascript! :giggle:
May 17th, 2002 at 8:53 am
nope… didn't work…
DOH!
Actually there's an ilayer tag around a layer tag… so maybe the ilayer is for NS, and the layer is for IE… Really weird script… And to think I was going to try and WRITE something that did that last night, now i'm kinda glad I gave up… would've ended up being a long night of frustration (and NO success!!) LOL!
May 17th, 2002 at 9:00 am
Inside the script, where you see this:
document.write('<span id="countupie" style="width:'+countupwidth+'; background-color:'+countupbgcolor+'"></span>')
try adding margin:20px into that style, like so:
document.write('<span id="countupie" style="margin:20px;width:'+countupwidth+'; background-color:'+countupbgcolor+'"></span>')
May 17th, 2002 at 9:00 am
…and Kristine??!! What's with keeping all the great tutorial links to yourself, huh??
Post em up on the resource page!!! LOL!
(I'll add that last one in now)
May 17th, 2002 at 9:01 am
Hmmm… the layers might override the div? I don't know, that made sense to me!
Nope, both are propriety Netscape tags. And according to this article at webreference even N6 doesn't support them! So I really don't understand why they are working now!!!

It is a really cool counter, though! Its neato that its real time
May 17th, 2002 at 9:05 am
well - that didn't do it either - that just added (white) space around it. LOL!
May 17th, 2002 at 9:07 am
There's also a countdown one too!
link
May 17th, 2002 at 9:07 am
NOW I got it… I changed the var "opentags" and "endtags" to include that open div (with the margin) and end div… YAY!
May 17th, 2002 at 9:08 am
Lynda, it says in the top of the script (when I view source) that adding height is only a NS4 attribute
LOL, I'm just searching google for things as I need them here! Although I do recognize both of these sites (webref and webdev), and really probably DO have them in my bookmarks
I'll try and spend some time going through my bookmarks this weekend and adding some stuff to the resources page
I'm a library over here! My sisters know that when they need indepth research, even if they've already searched, they come to me, and I'll always pull something up
May 17th, 2002 at 9:12 am
Try changing margin:20px to padding:20px;
Not sure what I was thinking.
May 17th, 2002 at 9:13 am
Okay, y'all are too quick for me. Although Kristine, I wasn't speaking of the height so I'm not sure what you're talking about.
Jenn's solution works, so awesome!
As for me, I will continue to stay away from Javascript at every turn because it royally confuses me. LOL.
May 17th, 2002 at 9:25 am
Okay, Lynda, you got me, I don't know where I came up with that. LOLOL!
That looks much better, Jenn! WTG!!!
I know that if I learn JS, my css knowledge will be more powerful…. I really need some more dHTML in my system. Maybe this afternoon, I'll find some links for the scripts I used for the header on my site. Which I think is bratta, but I won't spoilt it until this afternoon
It'll be a present to myself for making it through work 
And :giggle: I have a desire to know more JavaScript, but I just don't know enough yet to even understand more than copy and paste
May 17th, 2002 at 9:30 am
Kristine - are you talking about the fact that, for me, changing the var countdownheight has NO effect? For me it just uses whatever height layer it needs to display the timer. I wonder if changing the Overflow attribute might effect it? ::scurries away to have a look ::
May 17th, 2002 at 9:31 am
The thing I don't like about javascript is that it is client side, not serverside. A lot of stuff done with javascript can be done with PHP and if it CAN be done with PHP, I think it SHOULD be done with PHP as then it will work with everyone who can reach your page, not just people with the right browser.
The countup script can be done with PHP, although it can't change every second (just every time the page is loaded) because that requires the browser (client) to work.
Javascript also seems a bit more cryptic to me than PHP and I don't like how I can just view the source and get the code (makes people stealing scripts TOO easy)
It's just a personal thing with me. I've learned more about JS just being around Jenn, LOL - but I think javascript should be a last resort, so I try to look for PHP alternatives.
May 17th, 2002 at 9:35 am
Javascript can do some pretty cool things. I still like it…
…however - you can't DEPEND on it. I remember hearing that a scary number of people surf with javascript turned OFF! DOH!
It would be a good learning experience to try and figure out how to do that timer in PHP… Maybe that'll be my diversion this weekend.
May 17th, 2002 at 9:39 am
I like it on other people's sites, but I have reservations about adding it to mine.
And since I don't like using it on my own site, I don't think I'll ever get inclined enough to LEARN it.
May 17th, 2002 at 9:39 am
D'oh - should have read the description of the "clip" attribute:
This parameter specifies the clipping rectangle (viewable area) of the layer, which can be less than the width and height of the content of the layer. If the CLIP attribute is omitted, the clipping rectangle of a layer is the same size as the HTML content of the layer. A layer will expand to contain all of its content by default
May 17th, 2002 at 12:43 pm
long ramble between work projects…
I read what you said, Lynda, just before I walked downstairs for breakfast, so I thought more about this on the way to work.
I've thought for a long time that i should have a good working knowledge of JavaScript mainly because I should be able to do dHTML. Because CSS+JavaScript is cool.
But ya know what else is cool? There isn't a fancy name (that I know of) for CSS+PHP, but when I think about it, I have done some pretty neato stuff with just a simple stylesheet and a bunch of PHP includes - my portal being a prime example.
So maybe instead of focusing my energies on JavaScript, I should be learning more PHP
Not to say that I'll stop with JS - I'm using ImageReady-generated rollovers in a good portion of my graphic sets, and some dHTML scrollers…. but this thought came to me this morning, and I thought i'd share it 
May 17th, 2002 at 7:11 pm
Just what I asked for. Thanks so much.
May 17th, 2002 at 11:37 pm
Gaaaaaaahh!!!!!!!! Neato trick, but I hate it!! Completely crashed my browser the first time out, can barely type this comment, every time the count moves, I get the wait cursor…those of us with slower processors (120 mhz here) have a really hard time with things like this. Guess I need to stay away until this scrolls off the screen lol!
June 1st, 2002 at 7:47 am
Thanks marc!! :o)
August 17th, 2002 at 6:06 pm
small code for countdown til christmas. I think its working properly on my site.
<!—start of countdown—->
<?
$day = 25; // Day of the countdown
$month = 12; // Month of the countdown
$year = 2002; // Year of the countdown
// mktime is the marked time, and time() is the current time.
$target = mktime(0,0,0,$month,$day,$year);
$diff = $target - time();
$days = ($diff - ($diff % 86400)) / 86400;
$diff = $diff - ($days * 86400);
$hours = ($diff - ($diff % 3600)) / 3600;
$diff = $diff - ($hours * 3600);
$minutes = ($diff - ($diff % 60)) / 60;
$diff = $diff - ($minutes * 60);
$seconds = ($diff - ($diff % 1)) / 1;
printf("There are $days days, $hours hours, $minutes minutes, $seconds seconds until Christmas");
?>
<!—end of countdown >
September 19th, 2002 at 3:48 am
I'd really like to see that PHP countup script…
September 19th, 2002 at 7:44 am
Crystal - it's on this site..
here