Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jul 2003
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    A weekly variable counter.

    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?

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,731
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    <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.

  • #3
    New to the CF scene
    Join Date
    Jul 2003
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thank you

    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.

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,731
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    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.

  • #5
    New to the CF scene
    Join Date
    Jul 2003
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I see.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •