> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superoffice.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Ejscript element

> Ejscript element

This element is completely script-able.

1. The system loads a script and executes the global code of the script at instantiation time.
2. You create CRMScript functions for all the standard functions in [HtmlElement][1] and place those in the **Body** tab.
   * You can call `print()` to create output, or perform other actions on the element.

## Example

```crmscript theme={null}
Void element_printJavaScriptSection() {
  print("function mySetSizeFunction(width, height) { document.getElementById('myElement').style.width width* 4; document.getElementById('myElement').style.height = height* 4; }\r\n");
}
```

```crmscript theme={null}
Void element_setFieldValue(String field, Map map) {
  if (field == "setMessage")
    message = map.get("message");
}
```

## Functions

### getVariable()

All config variables are available using `getVariable()`.

### Print

| Function                        | Type | Called                                             | Comments                                               |
| :------------------------------ | :--- | :------------------------------------------------- | :----------------------------------------------------- |
| element\_printHeadSection       | Void | After the opening `<head>` tag                     | This is a good place to print embedded CSS code        |
| element\_printJavaScriptSection | Void | Inside a `<script>` tag in the head section        |                                                        |
| element\_printOnLoadSection     | Void | Wen the page is loaded (`HtmlPage_onload()`)       |                                                        |
| element\_printBodySection       | Void | When the body part of the element is to be printed | This is where you print your main HTML for the element |

### JavaScript and CSS

| Function                     | Type      | Description                                                                                                                                                                                                                     |
| :--------------------------- | :-------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| element\_getJsIncludes       | String\[] | Adds a list of JavaScript include files for the page                                                                                                                                                                            |
| element\_getCssIncludes      | String\[] | Adds a list of CSS include files for the page                                                                                                                                                                                   |
| element\_getSetSizeStatement | String    | Returns the opening part of a JavaScript statement that will be executed by the resizing model.<br />The available width, height, and closing parenthesis will be appended to this statement before it is evaluated (executed). |

### Values

| Function               | Type   | Parameters  | Comments                                                              |
| :--------------------- | :----- | :---------- | :-------------------------------------------------------------------- |
| element\_setValue      | Void   | String      | Sets a simple value for your element                                  |
| element\_clearValue    | Void   |             | Clears the value of the element                                       |
| element\_setFromCgi    | Void   |             | Called when the element should find its values from the CGI variables |
| element\_setFieldValue | Void   | String, Map | Sets a value or attribute for your element                            |
| element\_getFieldValue | String |             | Returns a value or attribute from your element                        |
| element\_toString      | String |             | Converts a simple value to a string                                   |

[1]: ../../../automation/crmscript/reference/CRMScript.Native.HtmlElement


## Related topics

- [MacroParameter](/en/automation/crmscript/reference/CRMScript.Native.MacroParameter.md)
- [Ejscripts](/en/api/archive-providers/reference/ejscripts.md)
- [ejscript table](/en/database/tables/ejscript.md)
- [screen_definition_action table](/en/database/tables/screen-definition-action.md)
- [ejscript_debug table](/en/database/tables/ejscript-debug.md)
- [Using the SearchEngine class in ejScript](/en/automation/crmscript/searchengine/using-the-searchengine-class-blog-post.md)
- [Enum values for EjScriptVerb](/en/database/tables/enums/ejscriptverb.md)
