Custom Lectora Variables Handled in Javascript

I am new to Lectora but have been developing HTML and Javascript for many years. I read other threads in this forum regarding how to capture Lectora variables in Javascript and convert them to local Javascript variables for further handling. Unfortunately, the solutions presented in those threads have not worked in my project.


Why doesn't my script capture the value of the custom Lectora variable, "FeedComments"?


The task is to capture text entered in an Entry Field and record it to the LMS in cmi.comments. I built a Feedback page with a Survey Question titled FeedbackInput which contains an Entry Field. I created a custom Lectora variable named FeedComments to which I assigned the initial value: "empty comments". I added a Submit button with no action assigned to itself; however, it has 2 actions assigned to it. Onclick the first action assigns FeedComments the value of FeedbackInput. The second action calls a custom function that is in an External HTML Object assigned as a Header Object. The script in this object is as follows:


function gld_FeedbackComments(){


var Var_Feed = "";


Var_Feed.setByVar(FeedComments);


var strFeedback = Var_Feed.value; // I also tried using Var_Feed.getValue();


LMSSetValue("cmi.comments",strFeedback);


}


I know that the call to the function and the SCORM call both work. I know this because a previous effort successfully accomplished the task but did so using an absolute reference to the Entry Field:


var strFeedback = entry475.objLyr.doc.forms["entry475form"]["Entry field"].value;


Absolute references will not work because I am building a "lesson template" that will be duplicated multiple times within a course as well as for many courses.


I would also appreciate any information concerning Lectora coding references (where to find listing of, uses for, and syntax information concerning custom coding in Lectora). I have been to the eProficiency site, any free on-line references?


Any assistance you can offer is greatly appreciated.


Paul S.

Discussion (1)

I am also facing the situation to set the lectora variables dynamically.


Referring to the solution above i have decided to use the .set() function.


I need to know whether it is a built in function or Function defined by Lectora.


Thanks in advance.


Regards

Vinoth

Discussions have been disabled for this post