Click to See Complete Forum and Search --> : Count the days up
send2me
12-09-2003, 09:30 AM
This should be an easy one for most of you. I'm looking for a script that will contain 2 small windows. The first is like a highest count record and the second will just need to count the days until I reset it in the script. Just getting the second window would even be nice. Basicly this is for counting the days of a accident free environment. When some one slips and hurts their brain, I need to be able to start the counter over.
Gollum
12-09-2003, 09:49 AM
try this...
<html><body>
It has been&nbsp;
<script type="text/javascript">
var dt = new Date(2003,0,5); // 5th Jan 2003
var now = new Date();
var nDays = Math.floor((now.getTime() - dt.getTime()) / 86400000);
document.write(nDays);
</script>
&nbsp;days since the last balls up.
</body></html>
send2me
12-09-2003, 10:02 AM
That is what I was looking for. You've saved me a ton of time. I was going to have to update this every day. The only reason I got this addition to my job was because I built a web page once. That was more then everyone else.
Thanks a lot.
send2me
12-09-2003, 11:03 AM
Is there a way to have this number on a button that I created? currently it displays off to the bottom or to the right of the button.
TheBearMay
12-09-2003, 11:27 AM
Give the button a name and instead of doing a document.write, set the value of the button:
<button name="chkBtn" ....>
<script>
...
chkBtn.value=nDays;
...
send2me
12-09-2003, 12:16 PM
I think I may have gotten that to work except that I can't see the number, it may be blended in with the button. Is there a way of changing the font and color of the text and can I add the text "days" to go with the script instead of putting it in the cell?
TheBearMay
12-09-2003, 01:09 PM
chkBtn.value=nDays+" Days";
send2me
12-09-2003, 01:40 PM
This is what I put in current.value=nDays+" Days"; Current is what I named the image. I'm not able to display anything in the button. Black is the default font color isn't?
TheBearMay
12-09-2003, 01:56 PM
Image? If you are using an image on the button it will override the text.
send2me
12-09-2003, 03:24 PM
Oh I see what you thought I was doing. What I did was create a gif image(button) in a cell and I wanted to display the number on top of that, but that may be a bigger and more complex script I'm guessing. Also, I tried using your code without a image and it isn't working. I'm not sure if I'm typing it wrong or what. I've try both of the following
chkBtn.value=nDays+" Days"; or
document.write=nDays+" Days";