- ELB Learning Knowledge Base
- Lectora®
- Programming
-
Lectora®
- Quick Win Tutorials
- Getting Started
- Modular Development (ModDev)
- Quick Guides
- Best Practices
- Navigating the Workplace
- Building a Title
- Importing Content
- Working With Text
- Working with Images
- Working With Objects
- Actions and Variables
- Tests, Surveys, and Questions
- Working with Web Windows or HTML Extensions
- Publishing a Title
- Creating Web-based, Accessible Content (Section 508/WCAG)
- Lectora Layouts
- Managing Titles
- Managing your Assignments
- Managing Your Notifications
- Communicating
- Admin Guide
- Lectora Player Skins
- Lectora Interactions and Scenarios
- Games
- Misc.
- Programming
- General
- Using Tracking for Progress, Status, etc
- Working with BranchTrack
- Trouble Shooting
- Working with Audio and Video
-
CenarioVR®
-
The Training Arcade®
- Arcades™
- Video Overviews
- FAQ's
- Recent Feature Videos
- Game Analytics
- Customer Feedback
- Demo Information
- General Admin
- Building Your Game
- Analytics
- Compatibility and Integrations
- Data, Security, and Privacy Policy
- JEOPARDY!®
- Jump
- Scenarios
- Trivia
- Trivia Virtual Instructor-Led Mode (VILT)
- Sort-It
- Scramble
- Recall
- Match
- Detective
- Translations
- New User Information
- Custom Branding Opportunities
- Registration and Leaderboard
- JEOPARDY!® Virtual Instructor-Led Mode (VILT)
-
MicroBuilder™
-
Asset Libraries
-
Rockstar Learning Platform
-
Rehearsal
-
Off-the-Shelf Training
-
ReviewLink®
-
The Learning Creation Studio
-
CourseMill®
-
General Topics
-
xAPI
-
Template Styles
-
Misc.
-
Articulate Storyline
-
Customizable Courseware
-
Course Starters
-
Camtasia
-
Group Administration
-
General
-
Can't find the answer? Ask our Customer Solutions team.
How can I manipulate Lectora User Variables in a Run JavaScript action?
Find out how to use Lectora User Variables in HTML Extensions and Run JavaScript Actions
Lectora Variables can be used within Lectora Actions, Conditionals, and Text Blocks to utilize dynamic content to drive branching and interactivity.
Sometimes you want to access these variable you defined to do some more sophisticated things using JavaScript. Here is a quick example of how you can do just that.
Example problem: I want to calculate a total for how many widgets I have if there are a defined number per box.
Lectora User Variables: TotalWidgets, NumberWidgetsInBox, NumBoxes
I can do this in a Lectora Run JavaScript Action with the following code:
VarTotalWidgets.set( VarNumberWidgetsInBox.getValue() * VarNumBoxes.getValue() );
The names used in JavaScript for User Variables are the Lectora User Variable name prefixed with "Var"
To set a value you must call the method <variable>.set()
To get a value from a variable you call the method <variable>.getValue()
Once you can set and get Variables in JavaScript it opens up a whole new world for extending Lectora. You can do anything in a Run JavaScript action or HTML Extension and then have the results available inside a Lectora User Variable for making branching (conditionals) decisions or to display results!