Newby
Posts: 0
Joined: Fri Sep 20, 2013 2:15 pm

Change UI Element valaue

Good Day.
I have screen where the user will input data financial data and on clicking the 'Calculate' button needs to calculate the 'installment' and show in 'Result' field.
Here is the code that is not working....

Can you please help.

var princ = Appery("loan").value();
var term = Appery("months").value();
var intr =Appery("rate").value() / 1200;
var getval = Appery("pay").text();
var payment = princ * intr / (1 - (Math.pow(1/(1 + intr), term)));
Appery('pay').text(payment);

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Change UI Element valaue

What exactly doesn't work? Do you know until line it does work?

Newby
Posts: 0
Joined: Fri Sep 20, 2013 2:15 pm

Change UI Element valaue

Hi Max,
I would expect the result of the calculation to show in textfield "pay" - get nothing happens when clicking on the caculate button.

When debugging i get a message "Uncaught error: Object has not method 'value'"

Thank you

Newby
Posts: 0
Joined: Fri Sep 20, 2013 2:15 pm

Change UI Element valaue

var princ = Appery("loan").value();

When debugging i get a message "Uncaught error: Object has not method 'value

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Change UI Element valaue

Please check the API here: http://docs.appery.io/javascript-api/

When using Appery(..) function, to read a value from an input component would be:

code
Appery('component_name').val();
/code

Appery(..) is just a small wrapper on top of jQuery.. for any API available, please refer to jQuery/jQuery Mobile docs.

Newby
Posts: 0
Joined: Fri Sep 20, 2013 2:15 pm

Change UI Element valaue

Hi Max. Thanks for the docs, but i have used them as reference already :)..

var princ = Appery("loan").value();

In this line i declare a variable 'princ' and wants to assign the value from the input field 'loan' to the variable - but is getting error as mention earlier.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Change UI Element valaue

It should be: Appery("load").val();

Newby
Posts: 0
Joined: Fri Sep 20, 2013 2:15 pm

Change UI Element valaue

Hi Max,
The field name is 'loan'
I want the value from input field 'loan' to be assigned to var princ....

Var princ = appery("loan").value

After the calculation, i want the value of the calcultion to be assigned to input field 'pay'

It is just a on screen calcultion and dont need to store any values once i move away from the screen.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Change UI Element valaue

Hello! Try this code:
prevar princ = Appery("loan").val();
//some calculations here
Appery("pay").val(princ);/pre

Newby
Posts: 0
Joined: Fri Sep 20, 2013 2:15 pm

Change UI Element valaue

Hi Guys,
I have tried the suggestion from Marina as well

"var princ = Appery("loan").val();
//some calculations here
Appery("pay").val(princ);"

...and it is not working.

The script needs to run on the click event....but i get an error message that the "Object doesn't support property or method 'value'"

Do i need to define \ declare anything else?
I have attached a screenshot of the debug screen.

My java script currently is

var princ = Appery("loan").value();
var term = Appery("months").value();
var intr =Appery("rate").value() / 1200;
var getval = Appery("pay").value();
var payment = princ * intr / (1 - (Math.pow(1/(1 + intr), term)));
Appery('pay').value(payment);

Image

Return to “Issues”