Need a Calculator to Populate Dates

Feb 05, 2016

Hi everyone--

I'm looking for a way for Storyline to generate five dates based on a "final" date submitted by the learner (learner submits any date they want). Each of the five dates calculates 30-10 weeks backwards from the final date.

For example, if the learner types August 1 as the final date, Storyline would calculate the following dates: Jan 4, March 28, April 25, etc. 

Any idea how to do this without needing coding? Thanks!

3 Replies
Steve Gannon

Hi Sarah,

(I posted this in reply to you over in the Storyline forum as well.)

I think the attached sample file accomplishes what you want. It uses Javascript to subtract the required number of days from the date the user enters. (Take a look at the code within the Execute Javascript trigger.)

For use in an actual project, you will probably want to add some error checking to caution the user if she enters a number out of range (e.g., as entering '13' for the month or '32' for the day). The script I drafted would require fewer variables and would be more efficient if I used a loop and more arrays but I wanted to make it relatively easy to follow in case you're new to Javascript.

A few caveats about using Javascript with Storyline:

1. You have to publish the project to see the results (it won't work in preview).

2. When passing variables back and forth between Javascript and Storyline, the exact same spelling of that variable must be used in both. In other words, you can't create a variable in Javascript and send that variable value to Storyline if the corresponding variable has not already been created in Storyline.

3. Javascript will not work with the Articulate Mobile Player app (but it will work with Flash and HTML5 output).

4. You may have to post the published output to a web server and run it from there because sometimes browser security settings restrict Javascript from running on a local drive.

Hope that gets you started!

This discussion is closed. You can start a new discussion or contact Articulate Support.