Page 1 of 1

Displaying sum of local variables from multiple pages

Posted: Fri Mar 15, 2013 2:35 pm
by Gavin Reynolds

Is it possible to pass local storage variables between pages and display the sum of the values?

For example:

Page 1
2 options available,

  • if the user selects option 'a', local system variable 'v1' is set to 1.

  • if the user selects option 'b', local system variable 'v1' is set to 0.

    Page 2
    2 options available,

  • if the user selects option 'a', local system variable 'v2' is set to 1.

  • if the user selects option 'b', local system variable 'v2' is set to 0.

    Page 3
    I would like to display the sum of 'v1' + 'v2' in a label.
    Is this possible? If so how?
    Are there any alternatives without using a database?

    Thank you!


Displaying sum of local variables from multiple pages

Posted: Fri Mar 15, 2013 3:00 pm
by Maryna Brodina

Hello! You can merge values and put the result into the Label using next JS code:

codevar sumValue = parseInt(localStorage.getItem('v1')) + parseInt(localStorage.getItem('v2'));
Tiggzi('labelComponentName').text(''+sumValue);/code

where labelComponentName - your component name


Displaying sum of local variables from multiple pages

Posted: Fri Mar 15, 2013 3:50 pm
by Gavin Reynolds

Fantastic, thank you!