When you select an element, a script button appears which looks like ‘</>’. Once selected the events that can be used in script are listed on the left hand side of the Script Template window. These events will differ depending on whether you select a Form, Page, Section, or an element that can accept input, such as a text box. Button elements have a unique event called ‘OnTap’ that is activated when the button is pressed.
You can quickly check if any scripting has been entered against an element’s events, by selecting the element and viewing the script button (‘</>’). If any scripts exist against events for the element the button will appear green, whereas if the element does not have any script against it, the button will appear grey. Commented out scripting will still show as green.
Selecting the script button will open the Script Template window and display the script for the highlighted event. If no code has been entered, a blank template will display with no events highlighted.
Properties are values that an element possesses. These properties include, “enabled”, “message”, “valid” and “visible”. When you use script to change these properties, you can change the way an element behaves or appears on the device.
Methods are instructions that you use to change an element’s properties. Normally you would use the Script Template window to place these method ‘calls’ in an element’s events. Most elements support the OnValidate() and focus() methods. The OnValidate method will run any code in the target element’s OnValidate event. The focus method will set the focus to the target element.
To set the focus to an element that is on a different page to that being viewed on the device, first use the form.changePage() method to select the required page. The format for using this is:
form.changePage("aliasName"), if an alias has been allocated to the page, otherwise, use the Page name. This must be enclosed in quotes, as in the example. As always, the instructions are case sensitive.
The format to use of the OnValidate() and focus methods is:
element.OnValidate(); and element.focus();