Use Current Date to Trigger Action

hplrsmom Community Member Posts: 31
Greetings! I created a page with 12 images representing each month in a year. They will animate in as audio narration is playing. I could just animate them in one at a time starting with January, but it would be cool to start the graphic on the month that the course is accessed. So if it's accessed today, the first month to appear would be August, then populate through July. As a test, I created an OnShow action to show the August graphic if variable CurrentDate contained August. I also tried <August>. When those didn't work, I created a hidden text box to contain the current date and a ChangeContents action to update it with CurrentDate. None of these worked.

Once I determine that I can do that, I need to figure out the best way to trigger the proper order regardless of the month. My thought is to create one action group for each month that plays the images in order, then use the OnShow Action to determine which one to play. My concern is that it might take a long time to process that calculation. I'm open to ideas.


  • timk
    timk Community Member Posts: 1,242 ✭ Legend ✭
    There seems to be a bug with the conditions panel... CurrentDate today contains "17.08.2017" (may be different where you are). If I check whether it contains "08" it works fine, only it would be true for "08.12.2017" as well. If I check for ".08" to make sure it can only be the month it won't work. It seems any "." in the value field breaks the code. CurrentDate equal to "17.08.2017" is not firing the action.

    I attached a sample in that I'm using a tiny bit of custom javascript to check which month we currently have, but most of it is pure Lectora.
  • smiller7502
    smiller7502 Community Member Posts: 181
    Interesting. For me, CurrentDate displays "Thursday, August 8, 2017". I'm guessing the value is based on the Windows default format for Long Date, but I haven't tested to confirm.

    In any case, once using JavaScript you can just use the JS Date() object as Tim as done. Alternatively, if there's some benefit to using Lectora's CurrentDate instead (I don't see one, but I wouldn't rule it out), this works:
    var dt = new Date(VarCurrentDate.value);
  • hplrsmom
    hplrsmom Community Member Posts: 31
    Stan, thanks for your response and your suggestion about the difference in how the date is presented. I appreciate your time in looking at this for me.
  • hplrsmom
    hplrsmom Community Member Posts: 31
    Tim, this is perfect; your sample does exactly what I need it to do. Thank you so much for taking time to put that together.