There are different applications of internal variables.
A) You can drag an "internal variables" question in the questionnaire page, and then address the variables via JavaScript, like the example that you postet. Make sure to run your script below of the question (or after the DOM was loaded).
If the page is reloaded, your script should first read the existing value from the hidden input, use it to initialize your script, and then modify the value eventually.
B) You can use prepare_input()
to tell SoSci Survey to watch out for a form element with a given name. That is, you would create an internal variable AB01_01
in your liust of questions, then add some html form element such as <input name="AB01_01">
and add the PHP code prepare_input('AB01_01')
that will tell SoSci Survey to read the data.
Note, that the second solution will not (!) automatically fill the previous answer into the input.
C) You can use the input elements provided by SoSci Survey. Let's say you created a text input TX01_01 (not an internal variable, but a differen question type) and want to place it somewhere in your HTML code, you use the palceholder %input:TX01_01%
. That is the easiest option to combine custom HTML code with inputs.