Gavin Reynolds
Posts: 0
Joined: Fri Mar 15, 2013 2:35 pm

Displaying sum of local variables from multiple pages

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!

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Displaying sum of local variables from multiple pages

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

Gavin Reynolds
Posts: 0
Joined: Fri Mar 15, 2013 2:35 pm

Displaying sum of local variables from multiple pages

Fantastic, thank you!

Return to “Issues”