Is there a variable to show the current year?

LisaB2022
LisaB2022 Community Member, Lectora® Accessibility Group (LAUG) Member, eLearning Brothers® Partner Posts: 37 ☆ Roadie ☆

I would like to automatically update the copyright year from 2022 to 2023 to etc.

Is there a variable for that?

Best Answers

  • andrew-robertson
    andrew-robertson Community Member Posts: 309 ♦ Idol ♦
    Answer ✓

    Without knowing if there is a built-in variable, I'd just run it through JavaScript.

    1. Add a textbox where you want your copyright statement to reside.
    2. Add an action under that text block that will Run Javascript on a the trigger OnPageShow.
    3. Add in the code below.
    4. 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.


    Andrew R.
    Developing content since 2010 using a mixed bag of tools.
  • andrew-robertson
    andrew-robertson Community Member Posts: 309 ♦ Idol ♦
    edited November 17, 2022 Answer ✓

    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.

    Andrew R.
    Developing content since 2010 using a mixed bag of tools.
  • andrew-robertson
    andrew-robertson Community Member Posts: 309 ♦ Idol ♦
    edited November 18, 2022 Answer ✓

    @LisaB2022 , 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 <Title> where anything with < > indicate text that is automatically modified on runtime.

    So for this example, you could use something like... <Copyright details here> in the textblock.

    Andrew R.
    Developing content since 2010 using a mixed bag of tools.

Answers

  • LisaB2022
    LisaB2022 Community Member, Lectora® Accessibility Group (LAUG) Member, eLearning Brothers® Partner Posts: 37 ☆ Roadie ☆

    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"

  • LisaB2022
    LisaB2022 Community Member, Lectora® Accessibility Group (LAUG) Member, eLearning Brothers® Partner Posts: 37 ☆ Roadie ☆

    @andrew-robertson 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.


  • LisaB2022
    LisaB2022 Community Member, Lectora® Accessibility Group (LAUG) Member, eLearning Brothers® Partner Posts: 37 ☆ Roadie ☆

    Yup that worked. Thanks again. 😁