Passing HTML extension value to lectora variable

jameshill
Community Member Posts: 13 ♪ Opening Act ♪
Passing HTML extension value"demo1" to lectora variable "bar_slider1"
I have been trying to pass a slider value to my lectora course. I have been through this and many other forums only to find explanations that fall short of actual giving me the answer. They show code that you should modify never show you what you actually need. So could someone please help me. I have attached the html content being displayed for you to view. I require the slider value which i take is "demo1" and i want that value passing to Lectora variable "var_slider1". How do i do it?
I have been trying to pass a slider value to my lectora course. I have been through this and many other forums only to find explanations that fall short of actual giving me the answer. They show code that you should modify never show you what you actually need. So could someone please help me. I have attached the html content being displayed for you to view. I require the slider value which i take is "demo1" and i want that value passing to Lectora variable "var_slider1". How do i do it?
Comments
-
What you actually need:
- A variable in Lectora
The variable needs a name, e.g. "slider1" - Awareness that Lectora renames variables during publication
A variable called "slider1" will be called "Varslider1" after publication, a variable named "var_slider1" in Lectora will be called "Varvar_slider1" - Slight modification of your current script
You have a function that inserts the slider value into that "demo1" span. The code to put the value into that Lectora variable would be "Varslider1.set(this.value);" (depending on the name of course) - You need to use that variable in a Lectora action otherwise it won't exist
- A variable in Lectora
-
wheels Florida USACommunity Member, Administrator, Moderator, Rockstar Manager Posts: 665 eLearning ROCKSTAR Admin TeamJust to add on to Tim's answer. You can find the JavaScript name of the Variable in the Variable Manager.
As Tim says use Varname.set() to set the variable and Varname.getValue() to get the current value.
Lectora Online identifies the JavaScript variable names in JavaScript and HTML Extension Header Scripting and includes them automatically. Otherwise you should do as Tim suggests and use a variable somewhere so it is included and available for scripting that is being done. -
-
OK thanks for your messages, so i have added an action to a submit button in lectora.
"Run JavaScript" and added the following:
Varname.getValue(this.value);
Var_slider1.set(this.value)
I get an error message after pressing the submit button "[OnMClkRunJS] ReferenceError: Varname is not defined"
What should "Varname" be? -
I know you're already on your way in this direction, however, in the future you might want to consider a CSS slider. Pretty easy to work with. The attached works fine with the wonky type of responsive programming this program outputs, however, I did not alter the JS for "seamless play" so if you want tot use it you'll have to target the parents - just don't use seamless. I posted this a while back and updated it with the newest minimized Jquery.
Just another option, there are numerous. Math's suggestion is a good way to go as well.
-
Sorry, I thought I included it in the zip. Here is the awt and some of the other support files in case you need them.
-
-
It works fine on its own. copy page and add assets and i get error, see attached
-
Categories
- 35.8K All Categories
- 108 ✫ Announcements
- 33.1K Lectora®
- 31.1K Lectora Discussions
- 28.9K Lectora Desktop
- 2K Lectora Online
- 2K Lectora Feature Requests
- 71 Lectora User Groups
- 36 Lectora Accessibility User Group (LAUG)
- 22 ELB Learning Content
- 22 ELB Learning Content Discussions
- 321 CenarioVR®
- 188 CenarioVR Discussions
- 133 CenarioVR Feature Requests
- 41 Rockstar Learning Platform®
- 38 Rockstar Learning Platform Discussions
- 108 CourseMill®
- 108 CourseMill Discussions
- 47 ReviewLink®
- 47 ReviewLink Discussions
- 5 The Training Arcade®
- 5 The Training Arcade Discussions
- 934 All Things eLearning
- 36 eLearning Development
- 546 Learning Management System (LMS) Integration
- 332 Web Accessibility
- 1.2K ♪ The Green Room
- 9 Additional Learning Products