JavaScript snippets
Dynamic content support (JavaScript inserts)
The system allows dynamic content to be inserted using JavaScript inserts. They can be used in the following places:
in components Formatted content (TextContent),
in components Label,
in properties Label available in other components.
Functionality does not include a component Formatted content (TextContent) placed in the area of the Footer.
JavaScript insert format
The inserts have the form:
<?js: return "value"; /** sample JS code returning a value */ ?>The content of the insert must always return a value (e.g. a string).
Usage examples
1. Returning a value depending on a form field
The insert below will return the text "m1. " only if the field with the identifier GesTextField1 has been filled in:
<?js: return getValue("GesTextField1") ? "m1. " : ""; ?>2. Handling default and custom values (session variables)
In the example below, if the variable customLabel is empty or has the value null, the value from defaultLabelwill be used.
Both values are available as session variables:
3. Insert with HTML formatting
Depending on the field value channel content containing HTML is returned dynamically:
Available JavaScript methods
As part of inserts, you can use the methods described in the section:
This allows, among other things, referencing field values, comparisons, checking for empty values, etc.
Important note on identifiers
In the content of inserts we do not prefix component identifiers or variable names with the symbol @.
Correct example:
Incorrect example:
Last updated
Was this helpful?
