Is there a variable to show the current year?
November 16, 2022 12:00 AM
I would like to automatically update the copyright year from 2022 to 2023 to etc.
Is there a variable for that?
Solutions (3)
Double check your quotes. Sometimes those single quotes will break the program. Can you share your module or something paired down?
Attached is a functional file.
Without knowing if there is a built-in variable, I'd just run it through JavaScript.
Add a textbox where you want your copyright statement to reside.
Add an action under that text block that will Run Javascript on a the trigger OnPageShow.
Add in the code below.
Bob's your uncle.
var tempYear = new Date().getFullYear();
text41.actionChangeContents('Copyright © ' + tempYear, 'alignleft','1');
Replace
text41
with your
HTML Name
of the copyright text block.
, you can add text to that blank textbox and once the JavaScript code is ran, it will replace its contents.
I typically add in some indicator text to all textboxes that have actions that modify them.. I know ELB Lectora uses something like
where anything with < > indicate text that is automatically modified on runtime.
So for this example, you could use something like... in the textblock.
Discussion (6)
Without knowing if there is a built-in variable, I'd just run it through JavaScript.
Add a textbox where you want your copyright statement to reside.
Add an action under that text block that will Run Javascript on a the trigger OnPageShow.
Add in the code below.
Bob's your uncle.
var tempYear = new Date().getFullYear();
text41.actionChangeContents('Copyright © ' + tempYear, 'alignleft','1');
Replace
text41
with your
HTML Name
of the copyright text block.
Double check your quotes. Sometimes those single quotes will break the program. Can you share your module or something paired down?
Attached is a functional file.
Thanks for responding so quickly Andrew. Unfortunately, I cannot get the current year 2022 to show. I will try again when I have more time. The only thing that shows in the text box is "My Copyright statement"
What a GREAT way to start out my morning! Thank you for the sample. I copied it added the organization name before copyright and ... Bob is my uncle ;)
For those who may try this for the first time, this is how your text box views on the screen with the javascript. Notice the text box is blank (I added the border so you can see where it is on the screen (since removed it so text appears as above). Because of this I separated the javascript text box from the original text box with the detailed agreement.
, you can add text to that blank textbox and once the JavaScript code is ran, it will replace its contents.
I typically add in some indicator text to all textboxes that have actions that modify them.. I know ELB Lectora uses something like
where anything with < > indicate text that is automatically modified on runtime.
So for this example, you could use something like... in the textblock.