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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with nesting an automatic year javascript

    Can this javascript:

    defaultStatus ="Copyright © 2004 XYZ, Inc. - All Rights Reserved."

    ...be modified so that the yr is automatic?

    I use the following script in my footer and was hoping it could be merged somehow/way with the status script above. Everything I've tried is producing errors.

    <script type="text/JavaScript">
    <!--
    today=new Date();
    y0=today.getFullYear();
    //-->
    </script> <script type="text/JavaScript">
    <!--
    document.write(y0);
    //-->
    </script>
    Last edited by AshleyQuick; 12-31-2003 at 06:51 PM.

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    This should do it

    <script type="text/JavaScript">
    <!--
    today=new Date();
    this_year=today.getFullYear();
    defaultStatus ="Copyright © "+this_year+" XYZ, Inc. - All Rights Reserved."
    //-->
    </script>

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,992
    Thanks
    203
    Thanked 2,536 Times in 2,514 Posts
    <script type="text/JavaScript">
    <!--
    today=new Date();
    y0=today.getFullYear();
    defaultStatus ="Copyright © "+ y0 + " XYZ, Inc. - All Rights Reserved."
    </script>


    Seems to work OK.

    Mr J beat me to it!

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts
    They both work great, thanks!

    Happy New Year!


  •  

    Posting Permissions

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