Page 1 of 1

using a local storage variable in javascript

Posted: Sun Jul 26, 2015 6:07 pm
by David7661654

Hello,

I defined a new javascript, in which I want to use a local storage variable called "destination".

The javascript I try to make is destinated to be used to convert a French e.164 number to a local number:
var dest={destination};
var formatted_destination = dest.replace(''+33","0");

The javascript doesn't accept the {destination}.

What should I do and how can I return the formatted_destination to a matching name local storage variable?

Thanks,

David


using a local storage variable in javascript

Posted: Sun Jul 26, 2015 11:39 pm
by David7661654

I tried to run the following line in Javascript (run Javacript on button click), but it gives me a null value in the alert box:

alert(localStorage.getItem('destination'));

What am I doing wrong?

Thanks


using a local storage variable in javascript

Posted: Sun Jul 26, 2015 11:53 pm
by David7661654

This doesn't work, either:

var dest = Apperyio.storage.storageVariable.get("$['destination']");
alert(dest);


using a local storage variable in javascript

Posted: Mon Jul 27, 2015 12:40 am
by David7661654

My bad.

I actually stored destination as a session storage, so to retrieve it in JS, I should have used

codealert(sessionStorage.getItem('destination'));/code


using a local storage variable in javascript

Posted: Mon Jul 27, 2015 5:38 am
by Alena Prykhodko

David,

Thank you for update.