Explore the community Forums Lectora Lectora Questions & Answers modify variable in html external bject

Viewing 1 post (of 1 total)
  • Author
  • #253263 Score: 0
    Profile photo of rupertab

    The only problem you have in your title is that Lectora does not know to declare your variable Total on the pages in question (that is why you get the javascript errors). Both of your methods of setting the Lectora variable work.The problem is that you access a Lectora variable within an external HTML object on a page and there is no other reference to the variable on the page. Since Lectora does not even try to figure out what you are doing in external HTML, it does not detect that you need the variable in question (Total) defined on the page. So how do you get it on the page? Easy … make a dummy reference to the variable on the page.   There are many ways to do this … but the easiest is to create an OnShow action at the title level that will show the button 1 object (which is shown by default so the action does nothing). The key is to put a condition on the action that uses the variable Total as part of it’s comparison.Create an Action at the Title Level called ‘Force Total On Page’. Make the Action an OnShow action and set the type of action to Show and set the destination to Button 1. Then click on the condition tab and turn on the Perform Action Only if … set the Variable to Total, the condition to “Equal To” and leave the value empty. This basically says the OnShow action will try to show the button (which shows by default) when the page loads if and only if the Total variable is empty.   Since you start it at zero, and the variable will only contain scores, the condition will always fail and the action will never run. However, the condition will have to be checked, thus Lectora will define the variable on the page for you. Now your external HTML objects can access the variable.BTW … the first method:external HTML type other:you can get rid of the tags if you change the type to “Header Scripting” like you do in the second attempt.Tim

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.