Search Support
-
Lukas PrützelMarch 25, 2020 at 5:41 am #5724
Hi,
We want to alter the Label / Text of a Button Element depending on the content of a TextArea Element.
To give you a better understanding of what we want to achieve and how we implemented it I’ll go into more detail on this:
The page contains a TextArea and a Button.
The TextArea contains a On change Event, that should alter the Button Label, as soon as the TextArea is filled with content.The code for the on change Event looks like this:
if (me.getText() == "") { page.ui.get("/Button").setText("Cancel"); } else { page.ui.get("/Button").setText("Import"); }
Thus, we expect the Button to be renamed to “Import” as soon as someone starts typing in the TextArea.
However, this is not the case. The Label change only occurs as soon as the user clicks out of the TextArea Element.Is this a known bug or are we using the Event incorrectly? If we can’t change the Button Label this way, can you demonstrate us a different solution that provides the expected result.
The issue also occurs when using a text input instead of a Text Area Element.
Thanks for your help and with best regards,
Lukas
SPARK SupportMarch 25, 2020 at 10:29 am #5729Hi Lukas,
You may want to try using the On Input event instead. The event has a “potential” context variable.
if(potential.length > 0) execute code;
Regards,
Stephen P
Lukas PrützelMarch 26, 2020 at 12:20 am #5730Hi Stephen,
This works perfectly! Thank you for your fast response.
Regards,
Lukas
-
|
You must be logged in to reply to this topic.