> For the complete documentation index, see [llms.txt](https://docs.eximee.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.eximee.com/documentation/documentation-en/budowanie-aplikacji/interfejs-uzytkownika/formularze/dynamicznosc-formularza/wstawki-javascript.md).

# 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.

{% hint style="warning" %}
Functionality *does not include* a component **Formatted content (TextContent)** placed in the area **of the Footer**.
{% endhint %}

### JavaScript insert format

The inserts have the form:

```js
<?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
<?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 `defaultLabel`will be used.\
Both values are available as session variables:

```js
<?js: return (getValue("customLabel") == "" || getValue("customLabel") == null)
    ? "${defaultLabel}"
    : "${customLabel}"; ?>
```

***

#### 3. Insert with HTML formatting

Depending on the field value `channel` content containing HTML is returned dynamically:

```js
<?js:
  return getValue("channel") == "mobile"
    ? "<b>Consent to telephone contact for marketing purposes.</b> <span class='optional' style='color:#bec2c3;'>(optional)</span>"
    : "Consent to telephone contact for marketing purposes. <span class='optional' style='color:#bec2c3;'>(optional)</span>";
?>
```

***

### Available JavaScript methods

As part of inserts, you can use the methods described in the section:

[**Condition definition expression language**](/documentation/documentation-en/budowanie-aplikacji/logika-biznesowa/jezyk-wyrazen-definiowania-warunkow-warunki-z-getvalue.md)

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:

```js
getValue("GesTextField1")
```

Incorrect example:

```js
getValue("@GesTextField1")
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.eximee.com/documentation/documentation-en/budowanie-aplikacji/interfejs-uzytkownika/formularze/dynamicznosc-formularza/wstawki-javascript.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
