...

View Full Version : A weekly variable counter.



MrSandman305
07-16-2003, 04:37 AM
I am have been trouble trying to create a counter that will every week add a set amount to a variable using Java. I have been trying a number of different things, but unfortunately, nothing has worked the way I have wanted it to. I simply want that at every Thursday, it will add 1 to a variable. Does anyone have any ideas?

Philip M
07-16-2003, 07:59 AM
<SCRIPT>
<!--
today = new Date();
day = today.getDay();
if (day==4){
yourvariablename+=1
//-->
</SCRIPT>

Or do you mean that you want the variable to be incremented
each Thursday and that value retained? If so you will need
either a server side language or perhaps a cookie.

You could also calculate the date using the date.getTime() function which returns the number of milliseconds since midnight on 1st January 1970. There are 604800000 milliseconds in a week.

MrSandman305
07-16-2003, 04:58 PM
I was actually looki9ng to have the variable retained and each week, it would become larger and larger. I do appreciate it and I'll fiddle with your code a little to see if it is what I need. If anyone has something else, that would be great too.

Philip M
07-16-2003, 07:15 PM
JavaScript has no capability to read from or write to
a file.

You need a server side language such as Perl, but then of course
what you want is very easy to achieve.

MrSandman305
07-17-2003, 03:47 AM
I see.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum