Text changed depending on current month
2 posters
Page 1 of 1
Text changed depending on current month
Technical Details
Forum version : #phpBB2
Position : Founder
Concerned browser(s) : Google Chrome
Who the problem concerns : Yourself
Forum link : http://hogas.huhohi.com/
Description of problem
Hey guys!Basically, lets say I have a div on all of my pages:
|
Depending on current month, I want the text to change.
For example:
January:
|
February:
|
March:
|
I am aware how to replace text wit scripts using IF clause.
I am not sure how to take current month as variable...
Any ideas, suggestions?
Last edited by Kami-sama on June 20th 2017, 6:17 pm; edited 1 time in total
Re: Text changed depending on current month
Hi,
This should do it:
Edit:You have to replace selector(from
with the class or id of the element you want the texts to be shown into.
This should do it:
- Code:
window.onload=function(){
var elem=$(selector);
var texts=[
"Text",
"Text",
"Text",
"Text",
"Text",
"Text",
"Text",
"Text",
"Text",
"Text",
"Text",
"Text"
];
var date=new Date();
var month=date.getMonth();
elem.text(texts[month]);
};
Edit:You have to replace selector(from
|
Guest- Guest
Re: Text changed depending on current month
mmm. does not seam to work. I only replaced this, so it should work....
|
Re: Text changed depending on current month
You forgot surrounding the selector with quotes. It should be like this:
.
|
Guest- Guest
Re: Text changed depending on current month
Oh, right hahahah. I did notice it saying "syntax error" XD
All good! Thank you.
Will this work also wit getTime and getYear ?
All good! Thank you.
Will this work also wit getTime and getYear ?
Re: Text changed depending on current month
Take a look here to find out more about the date methods in javascript:https://www.w3schools.com/js/js_date_methods.asp
This could be useful too:https://www.w3schools.com/jsref/jsref_obj_date.asp
This could be useful too:https://www.w3schools.com/jsref/jsref_obj_date.asp
Guest- Guest
Re: Text changed depending on current month
Problem solved & topic archived.
|
Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
Similar topics
» Color picker changed the text
» Is it possible to remove your ads for one month and to show google ads during that month, and if it's worth ?
» If the premium package is 600 Credits / Month, why is mine 760 Credits / Month?
» Under Construction: 1 week , 2 weeks, 3 weeks, 1 month, 2 month etc...
» Active forums depending on language
» Is it possible to remove your ads for one month and to show google ads during that month, and if it's worth ?
» If the premium package is 600 Credits / Month, why is mine 760 Credits / Month?
» Under Construction: 1 week , 2 weeks, 3 weeks, 1 month, 2 month etc...
» Active forums depending on language
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum