Andrew Clark
Posts: 0
Joined: Sun Jan 05, 2014 1:26 pm

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

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

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

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

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...

Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

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

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

Andrew Clark
Posts: 0
Joined: Sun Jan 05, 2014 1:26 pm

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

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.

Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

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

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

Return to “Issues”