Page 1 of 1

Sum a two figures one in input field one in label field drawn down from DB

Posted: Wed Nov 23, 2016 1:52 pm
by Andrew Clark

Hi

I know this should be easy and i have tried looking for answer but cant work it out:

I would like to calculate a sum. One item is unit price contained in label field which is drawn down from DB, the other is a dollar amount entered manualy in an input field.

I have created calculate script activated by a button

var price = Number (Apperyio("price").val());
var dollars = Number (Apperyio("dollars").val());

var day = price/dollars;

Apperyio('day').text('$' + day.toFixed(2)) ;

However I cannot seem to get it to calculate. I think the problem is it not picking up the value in the label field which is drawn down from database.

I have tried looking in get satisfaction but have not been sucessful in fixing problem

I would wecome any suggestions


Sum a two figures one in input field one in label field drawn down from DB

Posted: Wed Nov 23, 2016 6:47 pm
by Illya Stepanov

Hi Andrew,

You can check your variable value "day" using console.log() in the browser console to see the actual result and after that assign it to the text component value. Also good practice is to check the type of your data value stored in the variable with 'typeof()' -- here is a good article: https://developer.mozilla.org/en-US/d...


Sum a two figures one in input field one in label field drawn down from DB

Posted: Thu Nov 24, 2016 12:09 am
by Andrew Clark

thanks I will check that now


Sum a two figures one in input field one in label field drawn down from DB

Posted: Thu Nov 24, 2016 1:00 am
by Bruce Stuart

Specifically ... the data in your label field ... the value is not available via .val() its in .text()


Sum a two figures one in input field one in label field drawn down from DB

Posted: Thu Nov 24, 2016 1:49 am
by Andrew Clark

Bruce

Thankyou very much !! it worked. I knew it was something like that. I just have enough skills to to know in principle what is wrong, but not engough to resolve it in practice.

Hope you have a great day.


Sum a two figures one in input field one in label field drawn down from DB

Posted: Thu Nov 24, 2016 4:09 am
by Bruce Stuart

Andrew, my pleasure .... good luck with your app !