Assign Outsystems Session Variables or Local Variables with JavaScript

I have the following content inside an expression:

" <script type='text/javascript' class='source'>
$(function () {....

.... var testestring = JSON.stringify(v); ....


... represents content that don't metters. So, I need to assign the value of the testestring variable to an OutSystems session variable. How can I do this?

To assign the value of the Outsystems session variable to the testestring javascript variable I do the following:

" <script type='text/javascript' class='source'>
$(function () {....

.... var testestring = " + SessionVariable.teste +"  ....


But I need to do the oposite assignment. Is it possible?

Hello, Ricardo

Not sure if this is the most optimized approach, but you could create a hidden input assigned to the session variable, and write the result of testestring to it.

Good luck!

EDIT: BTW, if you searched for "Assign Javascript variable" you would find the answer. ;)
NOTE: At least in Firefox, a part of the example JS you wrote appears in the top of the page... (!?)
Hi Ricardo,

Following-up on the answer posted by Pedro Magalhães, you can see this forum post where you have an explanation on how to pass the value from a Javascript Variable to an OutSystems variable. The key aspect to understand the solution is:
  1. Javascript variable are client side variables (in your browser's memory);
  2. OutSystems variables are server side variables (in the server's memory);
  3. The easiest way to be able to pass information from the browser to the server, is to put the Javascript value in an input in the web page and somehow post that information to the server (eg. with an Ajax request) so that the value is stored in a server variable. See the forum post referred above for a more detailed description.
Kind Regards,

Daniel Lourenço