David wyatt
Posts: 0
Joined: Mon Sep 15, 2014 7:12 pm

Showing Javascript variable from html box in label

Hi,

i have a javascript form running in a html window, i need to show one of the variables in a label in side my app. Does anyone know if this is possible?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Showing Javascript variable from html box in label

Hi David,

If I understand you correctly, you want to take a value from some field of your form and inset in a Label component.

If you need to display a value on another app page, then I would recommend that you save a field value in a local storage variable and use it on another page to save in a Label.

David wyatt
Posts: 0
Joined: Mon Sep 15, 2014 7:12 pm

Showing Javascript variable from html box in label

sorry i wasnt very clear. in my html component i have javascript that creates a variable based on randomly generated number, i need this variable to be shown in a label and ideally in a input box too.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Showing Javascript variable from html box in label

Hi David,

[quote:]i have javascript that creates a variable based on randomly generated number"[/quote]
So you have a JavaScript variable (not a localStorage variable) and you want to use its value in a Label and/or in an Input component on the same page, right?

David wyatt
Posts: 0
Joined: Mon Sep 15, 2014 7:12 pm

Showing Javascript variable from html box in label

Yes thats right.

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

Showing Javascript variable from html box in label

Hi David.

At first you should create this variable in "window" context.
So to store this variable correctly you should use something like:

pre

window.someVariable = "somevalue";

/pre

Then you can use following code(for example in "page show" event handler) to set value stored in this JS variable(in window context) to some label component:

pre

//Where "labelComponentName" is your goal label component name.
Apperyio("labelComponentName").text(window.someVariable);

/pre

Regards.

David wyatt
Posts: 0
Joined: Mon Sep 15, 2014 7:12 pm

Showing Javascript variable from html box in label

Hi,

ive tried

window.score = 2;
Apperyio('score_label').text(window.score);

in my page load with score_label the name of my label. I have also tried it with a inputbox name and neither work.

ive also tried

Apperyio('score_input').val('2')

and

Apperyio('score_label').text('2')

and nothing is working

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Showing Javascript variable from html box in label

Hello David,

  1. Could you please clarify, do you try to change the text of the label on page show event?
  2. Can you get the item itself? What do you have in the console when running on the same
    preevent console.log( Apperyio('score_label') );/pre ?
David wyatt
Posts: 0
Joined: Mon Sep 15, 2014 7:12 pm

Showing Javascript variable from html box in label

hi
thats right i want the text in a label or input to show the value 2. i think there is an issue with my appery dashboard, as none of my javascript commands are working (including test commands from tutorials) and even my buttons set to navigate to another page arnt working

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Showing Javascript variable from html box in label

David,

Could you please share your project with a href="mailto:support@appery.io" rel="nofollow"support@appery.io/a and tell us its name and steps to reproduce the issue? http://devcenter.appery.io/documentat...

Return to “Issues”