Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6083379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:23:48+00:00 2026-05-23T11:23:48+00:00

I needed a JS that would change the content of these two div’s every

  • 0

I needed a JS that would change the content of these two div’s every day on a yearly basis. For example: on Jan 1 the date div would be “JAN 1” and the moto div would be some moto for Jan 1, then on January 2 the date and the moto changes but not randomly I have text for each of the 365 days. So just a example and I can fill out the rest. I thought JS but can be PHP on serverside if easier.

<div id="date"><h3>JAN 1</h3></div>
<div id="moto" align="center">Example Text.</div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:23:49+00:00Added an answer on May 23, 2026 at 11:23 am

    Just to humor your request I’ve provided a solution…like the other answers say, though: this is best done server-side.

    <script>
        var date = new Date(); //get current date
        var month = date.getMonth();
        var day = date.getDate();
        var months = ['JAN', 'FEB', ... , 'DEC']; //array of month formats
    
        //define mottos as a multi-dimensional array by month and day
        var mottos = [
            [
                'JAN 1 Motto',
                'JAN 2 Motto',
                ...,
                'JAN 31 Motto'
            ],
    
            ...,
    
            [
                'DEC 1 Motto',
                ...,
                'DEC 31 Motto'
            ]
        ];
    
        //set the Date DIV
        document.getElementById('date').innerHTML = months[month] + " " + day;
    
        //set the Motto DIV; the day - 1 accounts for the zero-indexed arrays
        document.getElementById('moto').innerHTML = mottos[month][day - 1];
    </script>
    

    With PHP:

    <?php
    
        //Similar to the above JS method
        $mottos = array(
            array(
                'Jan 1 Motto',
                ...
            ),
            ...
        );
    
        $date = new DateTime();
        $month = (int) $date->format('n');
        $day = (int) $date->format('j');
    ?>
    
    <div id="date"><h3><?php echo strtoupper($date->format('M j')); ?></h3></div>
    <div id="moto" align="center"><?php echo $motto[$month - 1][$day - 1];</div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was just working on a function that I needed to return two values,
If I had a java application that needed specific environment variables to be set,
I needed a function that simply checks if a string can be converted to
There is a conversion process that is needed when migrating Visual Studio 2005 web
I have a source code that is needed to be converted by creating classes,
I have classes that are needed in both my web service and my server.
I was given an .xml file that I needed to read into my code
I have a class file that contains all the classes that are needed for
I have a rather huge query that is needed in several stored procedures, and
I bumped into an additional question that I needed in regards to this: Using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.