Schedule text to show based on date
Author: Ionescu C.
Visited 1384,
Followers 1,
Shared 0
Hello,
Is there any option available to schedule text to show based on date?
I know there is for the post section that are within the blog section.
But I was asked for a text or picture to show on certaint dates, for example a daily section where the user is asked a new question each day, thus making the website more attactive.
Looking forward for your answers.
Regards,
Cristi
Posted on the
(It > En) ... paste this code into an HTML Code Object, and the rest you will understand for yourself:
<script>
giornoSettimanaK = new Date()
if (giornoSettimanaK.getDay() == 0) { document.write("testo Domenica") }
if (giornoSettimanaK.getDay() == 1) { document.write("testo Lunedì") }
if (giornoSettimanaK.getDay() == 2) { document.write("testo Martedì") }
if (giornoSettimanaK.getDay() == 3) { document.write("testo Mercoledì") }
if (giornoSettimanaK.getDay() == 4) { document.write("testo Giovedì") }
if (giornoSettimanaK.getDay() == 5) { document.write("testo Venerdì") }
if (giornoSettimanaK.getDay() == 6) { document.write("testo Sabato") }
</script>
.
ciao
.
Author
Hello,
Thank you for the idea, it is the best that I have ever found until now.
Can you tell me if I want to scheduel for more than one week, just continue with the script 7, 8, 9 or go with the day of the month, for example for today 16'th, tommorrow 17'th ?
<script>
giornoSettimanaK = new Date()
if (giornoSettimanaK.getDay() = 16) { document.write("testo Domenica") }
if (giornoSettimanaK.getDay() = 17) { document.write("testo Lunedì") }
if (giornoSettimanaK.getDay() = 18) { document.write("testo Martedì") }
if (giornoSettimanaK.getDay() = 19) { document.write("testo Mercoledì") }
if (giornoSettimanaK.getDay() = 20) { document.write("testo Giovedì") }
if (giornoSettimanaK.getDay() = 21) { document.write("testo Venerdì") }
if (giornoSettimanaK.getDay() = 22) { document.write("testo Sabato") }
</script>
Thank you,
Cristi
... ...
<script>
var day_16_1 = "aaaa aaa aaa XXX";
var day_17_1 = "bbb bb bbbb bb";
// etc. etc.
dateK = new Date();
dayK = dateK.getDate();
monthK = dateK.getMonth() + 1;
K = "day_"+ dayK + '_' + monthK;
document.write( eval(K));
</script>
.
ciao
.
Author
Hello,
Can you please help me with something regarding this code?
The script it is very good, it does what I wanted.
I want to add a question and under the question some text as description.
When I hit enter to go on the next line, the script is not working anymore.
<script>
var day_12_2 = "question text?
This is the description section which I wanted to show underneath.";
var day_12_2 = "Today is 30.01.2021";
// etc. etc.
dateK = new Date();
dayK = dateK.getDate();
monthK = dateK.getMonth() + 1;
K = "day_"+ dayK + '_' + monthK;
document.write( eval(K));
</script>
In the above example the script is not working.
Regards,
Cristi
... I do not understand! ... maybe like this?
.
Author
Hello,
I want to add more details that will be shown based on the date.
Now if I will use a small text - everything is working fine.
If I want to add a more elaborated text, that envolves pressing ENTER (because I want info to be shown under the first paragraph or by inserting <p> text </p>), the script doesn't output the text anymore.
I have notice that the text when it is working fine, it has a blue like color, after trying to insert a new paragraph (on the same var), or just pressing enter, the text is displayed all in black.
Maybe it is better explained now.
Regards,
Cristi
... you can articulate the text as you like dynamically for each different day, ... but on the ENTER button which is not part of my code, I don't know what to tell you, ... I'm sorry ...
Hi
Author
Hello,
In the end I have discovered the solution:
var day_14_2 = "Question that I want to ask? <p>Description of the question asked</p>";
var day_15_2 = "Today 15.02.2021";
Because of the sign "?" I wasn't able to show the next paraghraph underneath, as I wanted to be diplayed.
Thank you for the support!
Regards,
Cristi
... that is, like the first two lines of my STAMP...?...
... or something I still don't understand...?...
ciao
.
Author
Yes!
The output is liek you mentioned it.
But I didn't know how to put it in code format.
Regards,
Cristi
... OK ...
<script>
var day_15_2 = "question text? <br> This is the description section which I wanted to show underneath.";
// var day_ etc. etc.
dateK = new Date();
dayK = dateK.getDate();
monthK = dateK.getMonth() + 1;
K = "day_"+ dayK + '_' + monthK;
document.write( eval(K)); //<by K>;
</script>