David Lewis
Posts: 0
Joined: Sun Mar 01, 2015 9:06 pm

Set variable in local storage? (New update)

Since the update, some of the features for setting local variable are not working. For example, I try to set a variable using the Events area, but the Value input only has a dropdown menu with no options.

I only ask because all of the tutorials are from over a year ago, and the UI has changed considerably.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Set variable in local storage? (New update)

Hi David,

Please show us more details about this problems.
Some screen shots will be great.

Thanks.

David Lewis
Posts: 0
Joined: Sun Mar 01, 2015 9:06 pm

Set variable in local storage? (New update)

Sure. Here is the relevant code, then the screenshot (see other reply) of the Event window. My app is a basic calculator, so it needs to pull in user input. I could just be coding wrong (new to Javascript).

var majd = Number(Apperyio("majd").val());

if (majd === 0) {
alert ("Please enter number 0.");
return;
}

var decmd = eval(majd);

var TPI = Number(Apperyio("TPI").val());

if (TPI === 0) {
alert ("Please enter number 0.");
return;
}

var n = Number(Apperyio("n").val());

if (n === 0) {
alert ("Please enter number 0.");
return;
}

var tlength = Number(Apperyio("tlength").val());

if (tlength === 0) {
alert ("Please enter number 0.");
return;
}

var offset = Number(Apperyio("offset").val());

if (offset === 0) {
alert ("Please enter number 0.");
return;
}

var feed = 1/TPI ;
var k = 0.759/TPI;
var mind = majd-(kval2);
var d = kval/(n0.5);
var xcham = mind-0.005;
var zcham = 0-feed;
var g54x = majd+0.05;
var g54z = 3feed;
var zthread = tlength+offset;

Apperyio('feed').text(feed.toFixed(2)+'in./rev');
Apperyio('kval').text(kval.toFixed(2));
Apperyio('mind').text(mind.toFixed(2)+'in.');
Apperyio('xcham').text(xcham.toFixed(2)+'in.');
Apperyio('zcham').text(zcham.toFixed(2)+'in.');
Apperyio('code').text('G00 G54 x'+g54x.toFixed(2)+'z'+g54z.toFixed(2));
Apperyio('code2').text('G76 F'+feed.toFixed(2)+' X'+majd.toFixed(2)+' Z'+zthread.toFixed(2)+' K'+k.toFixed(2)+' D'+d.toFixed(2));

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Set variable in local storage? (New update)

Hi David,

Unfortunatly i can not see using local storage in your given code.

It still not clear about your problem please try to explain it to clarify.

Also - please check if you have any errors in browser console.

Thanks.

David Lewis
Posts: 0
Joined: Sun Mar 01, 2015 9:06 pm

Set variable in local storage? (New update)

As I said, I'm new to JavaScript. I'm trying to pull user input into basic calculations, then print the results to another page in the app. I tried copying your site's basic tip calculator format, but the output does not appear on the screen.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Set variable in local storage? (New update)

Hi David,

For this goal you don't need this lot of code.

Here is a brief plan:

  1. On first page (where are your components) on some event(for example button click) you need to place following JS code(with your modifications):

    pre

    //Where "firstNameInputName" is your input component name.
    var firstName = Apperyio("firstNameInputName");

    //Where "lastNameInputName" is your input component name.
    var lastName = Apperyio("lastNameInputName");

    var name = firstName + " " + lastName;

    alert("name = " + name);

    //Store name value to "name" lsv
    localStorage.setItem("name", name);

    /pre

  2. On second page(where you want to see data from first page) you can use following js code(with your modifications):

    pre

    //Where "labelName" is your label component name.
    var nameLabel = Apperyio("labelName");

    //Get value from LSV
    var name = localStorage.getItem("name");

    //set value to the label.
    nameLabel.text(name);

    /pre

    Note, it just an example of what you want to implement that shows how to work with local storage and appery.io components. You should modify it in accordance to your needs.

    Regards.

David Lewis
Posts: 0
Joined: Sun Mar 01, 2015 9:06 pm

Set variable in local storage? (New update)

It is still getting stuck with a gray, swirling loading icon now. My code pretty much matches yours, but the final page will not load for some reason

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Set variable in local storage? (New update)

Hello David,

Please try to debug your project http://devcenter.appery.io/documentat...
Are there any errors in browser console?

David Lewis
Posts: 0
Joined: Sun Mar 01, 2015 9:06 pm

Set variable in local storage? (New update)

No errors. It's simple math code in JS. It keeps getting stuck on the loading icon in between the input page and output page.

Return to “Issues”