4.4 - Adding JavaScript code
There are a few options available to add JavaScript code within your answerSpace:
Within a Message or mADL Interaction
In a .js file within the asset manager
In a separate Interaction within an answerSpace
Referencing an external source eg. hosted library
Step 4 of the Forms Builder (customisation step)
Step 3 of the Forms Builder (Calculation field)
Within a Message or mADL Interaction
All Message type Interactions function similarly to a HTML page. This means you can add HTML tags, including <script> tags within Message Interactions.
All mADL type interactions run PHP script, you can add JavaScript to these interactions in the same way that you would normally add JavaScript within PHP code.
In a .js file within the asset manager
If you prefer to store your JavaScript in an external file, you should upload the .js file to the asset manager (Manage... -> Assets) and reference it in your AnswerSpace Setup (AnswerSpace Setup -> Load External Javascript)
Save JavaScript in a separate Interaction within an answerSpace
Create the Interaction, add the appropriate JS code and reference the Interaction in your AnswerSpace Setup (AnswerSpace Setup -> Load External Javascript)
Use the following format within Load External Javascript:
//blinkm.co/_api/interaction/run/answerSpaceName/interactionName
Referencing an external source eg. hosted library
Add the appropriate reference to the external source to the Load External Javascript area within your AnswerSpace Setup (AnswerSpace Setup -> Load External Javascript)