SharePoint / JavaScript Tip/Theme of the day

Hi experts,

I have been asked to add a theme of the day to our Intranet (SharePoint 2013) homepage.

There will be 31 themes (one for each day in a calendar month) and they will be repeated every month. For example Theme 1 = Working together, so every 1st of of the month, that theme should display
Theme 2 = Recognising special effort, so on the 2nd of every month, that theme should display instead.

To make it simple, I plan to store the themes as images in a library. e.g. 01.png, 02.png and thinking the easiest way would be a simple javascript that does something like... (PS - I don't know JavaScript (well) so forgive the psuedo code below,..)

£path = "" /* base path */
$themeURL = $path & left(now,2) & ".png" /* add the path to today's image based on the day of today's date */
getElementByID("theme_of_the_day").innerHTML="<IMG SRC=""" & themeURL & """>" /* set div to that image URL */

Thanks in advance!
Martin ZAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

    var d = new Date();
    var n = d.getDate();
    var path = "";
    var currentImg = path+n;
    var themeURL = currentImg + ".png";
    document.getElementById("theme_of_the_day").style.background="url(themeURL) left top no-repeat 100% 100%";

Open in new window

It will take image automatically according to date. You need to keep 31 images inside theme folder.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Martin ZAuthor Commented:
Thanks Jamie!

Using the links you provided I created a minimal JavaScript to load the image (assuming the name matches)...

​​​​<script type="text/javascript">
var img_location = "";
var currentdate = new Date();
var day = currentdate.getDate();
document.write('<img src="' + img_location + day + '.png">');

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SharePoint

From novice to tech pro — start learning today.