Michael Maresca
Posts: 0
Joined: Tue Feb 18, 2014 7:14 pm

Helpppppp :( with javascript for local variable storage

Hey so I am really new at this and trying to figure out basic local storage. I want to store what was inputted on one page and display it on the next
The first issue I have is how to read the text (which should be a number) in the input. The name of the component I want read has been changed to age.
Should it be something along these lines?

To save the object (I don't know if this is addressing the text in the box named input or not) The name of the app page is name and the input name is age

Something like this?
To Store Object
result = document.name.age.value
var input = localStorage.setItem("nickname", result).;

To retrieve Object
localStorage.getItem('nickname');
document.result.age.value = ('nickname')

Just to be clear what Im trying to do,
1) Access number input in the component named "age" on page named "name"
2) store that number to local storage
3) on the page named "result" retrieve the local stored number
4) have number displayed in label named age.

I know that this is not correct but I have never done this before, currently looking into learning techniques but any assistance would be appreciated.

Michael Maresca
Posts: 0
Joined: Tue Feb 18, 2014 7:14 pm

Helpppppp :( with javascript for local variable storage

Thank you I would use this method but I want to multiply the two variables together at the end and from my understanding you can't do that using this method

Michael Maresca
Posts: 0
Joined: Tue Feb 18, 2014 7:14 pm

Helpppppp :( with javascript for local variable storage

Thank you I would use this method but I want to multiply the two variables together at the end and from my understanding you can't do that using this method

Matt6607699
Posts: 0
Joined: Sat Jan 25, 2014 7:18 am

Helpppppp :( with javascript for local variable storage

Local storage carries from page to page so if you save the age input value to a local storage var on the "name page", you will be able to retrieve the value in the results page. You may have to use something like:

Name Page
Design view - Events tab: on click(submit_button_name), set local storage variable.
Enter whatever variable name you want to use. ex. local_age
click bind to component checkbox.
select "age" component.
Property name = Text
save

Results Page
label cant be the same name as input component from "name page" ex ageLabel
Design View -Events - "Results page" - Load - Run Javascript:
var userAge = localStorage.getItem("local_age");
Appery("ageLabel").text(userAge);
save

Hopefully this get you where ya need.

Michael Maresca
Posts: 0
Joined: Tue Feb 18, 2014 7:14 pm

Helpppppp :( with javascript for local variable storage

Ok Thank you but now I know that they are properly storing as I can retrieve them individually using their variable name, could you please explain how to multiply the two together?

Michael Maresca
Posts: 0
Joined: Tue Feb 18, 2014 7:14 pm

Helpppppp :( with javascript for local variable storage

Ok Thank you but now I know that they are properly storing as I can retrieve them individually using their variable name, could you please explain how to multiply the two together?

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Helpppppp :( with javascript for local variable storage

Hi Michael.

If you have saved two numbers into the two local storage variables (LVS) you can get and multiply them using following code:
pre
var firstNumber = parseFloat(localStorage.getItem("local_firstNumner"));
var secondNumber = parseFloat(localStorage.getItem("local_secondNumner"));
var multiplyResult = firstNumber * secondNumber;
Appery("resultLabel").text(multiplyResult);
/pre

Return to “Issues”