Search.../

onChange( )

Adds an event handler that runs when the mobile picker element's value is changed.

Description

A mobile picker element receives a change event when a mobile app user changes the value in the mobile picker element.

A change event is not triggered when you change the mobile picker element's value using the element's value property.

Because onChange() is fired before validations are performed, do not check any of the validation properties in the onChange() event handler. For example, do not code an if statement that checks the valid property in the onChange() because the property at this point contains values prior to the onChange().

Syntax

function onChange(handler: EventHandler): MobilePicker
handler: function EventHandler(event: Event): void

onChange Parameters

NAME
TYPE
DESCRIPTION
handler

The name of the function or the function expression to run when the mobile picker element's value changes.

Returns

The mobile picker element on which the event is now registered.

Return Type:

EventHandler Parameters

NAME
TYPE
DESCRIPTION
event

The event that occurred.

Returns

This function does not return anything.

Return Type:

void

Was this helpful?

Get the value of the element that was changed

Copy Code
1$w("#myMobileElement").onChange( (event) => {
2 let newValue = event.target.value; // "new value"
3});
Enable the submit button when an option is selected

Copy Code
1$w('#submitButton').disable();
2$w('mobilePicker1').onChange( (event) => {
3 if ($w('#mobilePicker1').value) {
4 $w('#submitButton').enable();
5 }
6});