How to pass value asynchronously from javascript to Local Variable

How to pass value asynchronously from javascript to Local Variable

  

Hello.


I want to create stopwatch function in my application without some plugins.


Please check attached file.

In JS named start inside Client Actions "ButtonOnClick",

I wrote following codes to update showing time.

document.getElementById("timerValue").innerHTML = getDrawingTime(time, inflatedTime);

If possible, I'd like to update a Local Variable "timeString".

Does anyone know?

Assuming you have JQuery available.

$('#timerValue').val(getDrawingTime(time, inflatedTime));

// I don't really remember on what event outsystems has it's handler
$('#timerValue').trigger('change');
$('#timerValue').trigger('onChange');


This will trigger the onChange handler of OutSystems, if you link the input with your local variable it should now be updated with the new value.

Dear Claring

Thank you for information.

I use only javascript so I made a silimilar JS code and it didn't work.


I have applied to the support service for information.

I think it will be resovled.

Thanks!

Hi Mio,

The Id of an Html element and the property Name of an element have not the same value. To get the Id of an Html element you have to access it with <name>.Id.

That said, see if this works for you:

  • Create input parameter for "start" Javascript statement. Give it the name "timerValueId".
  • Change line 10 to: var showedTime = document.getElementById($parameters.timerValueId).innerText;
  • In the properties of the "start" Javascript statement add the value "startTimer.Id" to the property "startTimerId"

Cheers,

José