31
Views
2
Comments
Solved
Assigning value to element in JavaScript Input event handler not updating variable
Application Type
Reactive
Service Studio Version
11.55.6 (Build 63936)

I have an input event handler in JavaScript which is used to modify the input. Modifying this.value in the input event handler function changes the value displayed in the element (input box), but the value of the OutSystems variable bound to that element is not updated.

(The reason for changing the value in the input event handler was to format the input in the input box as the user types.)

E.g., In the attached OML, the JavaScript modifies this.value to append a "." on the input event, but the value displayed in the message when the button is clicked is still the old value "hello". However, when the input event handler function does not change this.value, the value displayed in the message is the updated input box value as expected.

Can someone please explain why the value is not getting assigned to the OutSystems variable when the input event handler modifies this.value?

As a workaround (not shown in the OML), in the submit action, I had to take the value from the input box instead of from the OutSystems variable.

JavaScriptEventHandler.oml
2024-06-24 15-21-58
Ahmed Hani
Solution

Hello Tushar,

Your question is similar to another answered question by Tigo Rodrigues
You can find the question and answer here: https://www.outsystems.com/forums/discussion/97102/trigger-the-change-of-a-bind-variable-by-changing-an-input-value-with-javascript/

I've attached an oml with the implemented solution.

JavaScriptEventHandler-fixed.oml
UserImage.jpg
Tushar Ram Godbole

Thank you for the reply. The solution you have provided is working.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.