HOME ➔ SUPPORT ➔ Community ➔ General CourseLab issues ... HTML Variables
HTML Variables
  View type:
Dear my friends
I have a simple HTML code :
<input type="text" name="Data" size="20" value="23">
I open this HTML file via courselab. Then I want to read this variable via courselab javascript. How can I do it or How can I send this variable from HTML file to courselab?
Hi, Hanif,

If this HTML is in the same CourseLab document (i.e. the same DOM) then you can use JAVASCRIPT action with usual DOM addressing, i.e.

var myFieldValue = document.getElementById('myFieldID').value;
g_arSlideVars['my_CL_var'] = myFieldValue;

After that you will have CourseLab varible named "my_CL_var" with value from field.

But why use this plain HTML? There is text field object in CourseLab and it saves value in variable automatically.
This is in an external file you are having opened by Courselab inside the module?
I guess you want to have a way of changing variables that does not mean changing the module, just an external file or page.
To get this value isn't easy and as Slav says it would be much better to have the variable defined inside of Courselab.
Message options
No additional options