When an event has been added to a component in FormMaker, there are a number of properties made available to any 'Custom Script' actions you may define for the event.
These properties are all accessed through the objEventSource object, and are detailed in the table below. Please note that not all of these properties will apply for page level and external events.
Using these properties removes the cross browser complexities involved in accessing these event related details.
Examples:
To access the value of a textbox field in an onchange event:
alert(objEventSource.field.value) [or more simply: alert(this.value)]
To find the type of an event (eg onclick, onchange etc)
alert(objEventSource.event.type)
To find the mouse coordinates of an event:
hyf.util.getMouseCoords(objEventSource.event) [this returns an object with x and y properties]
These properties are all accessed through the objEventSource object, and are detailed in the table below. Please note that not all of these properties will apply for page level and external events.
Property | Description |
---|---|
option | Indicates what this event was registered against. Valid values are 'field', 'label', 'group', 'grouplabel', 'page' and 'external' |
event | The javascript event object |
value | The id of the field or group that this event was registered against |
repeatId | If the component that the event is registered on is contained within a repeat (eg in a table structure) then this property will contain the id of the specific entry within the repeat (eg the row) that the event was fired for. The 'value' id needs to be prefixed with this string to get the full id of the HTML object. |
field | The HTML object (eg text box) that the event was defined against. This is often the component you are interested in, and can usually be accessed with the 'this' keyword. |
component | This is the HTML component that was the target of the event. This may or may not be the same as the 'field' due to event bubbling. For example if an onclick event is defined against a group, and the user clicks on a contained text box, this property would reference the textbox, where as the field property would contain the HTML element for the group (eg a DIV) |
Using these properties removes the cross browser complexities involved in accessing these event related details.
Examples:
To access the value of a textbox field in an onchange event:
alert(objEventSource.field.value) [or more simply: alert(this.value)]
To find the type of an event (eg onclick, onchange etc)
alert(objEventSource.event.type)
To find the mouse coordinates of an event:
hyf.util.getMouseCoords(objEventSource.event) [this returns an object with x and y properties]