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?
Catch up wih the Appery.io community on our forum. Here you'll find information on the lastest questions and issues Appery.io developers are discussing.
https://forum.appery.io/
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?
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.
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.
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?
Yes thats right.
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.
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
Hello David,
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
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...