This is the code :
var Item1 = Appery('mobilelabel_5').val(110),
Item2 = Appery('mobilelabel_4').val(90);
Appery('mobilelabel_7').text(Item1+Item2);
All is get is Object object Object object
This is the code :
var Item1 = Appery('mobilelabel_5').val(110),
Item2 = Appery('mobilelabel_4').val(90);
Appery('mobilelabel_7').text(Item1+Item2);
All is get is Object object Object object
Hi David,
First you'll need to determine with what data types you'll be working.
Labels - stores strings, so you'll need to convert them to the integer code parseInt();/code(or float, if needed codeparseFloat();/code).
Let's make our situation a little clear:
ol
liWe have "mobilelabel_5" and "mobilelabel_4" and "mobilelabel_7" labels.
/liliWe need to get values from "mobilelabel_5" and "mobilelabel_4" add them to each other./li
liResult of 2nd step put as text into "mobilelabel_7" label.
So for this purpose you should use the following code:
precode
var item1 = parseInt(Appery('mobilelabel_5').text());
var item2 = parseInt(Appery('mobilelabel_4').text());
var result = item1 + item2;
Appery('mobilelabel_7').text(result);/code/pre/li
Regards./ol
what if it is digit?
do i use .val or .text?
Sorry, didn't clarify on this -- integer and float are both digits - integer is a digit without comma and float is digit with comma (like 120,56).
Method code.val();/code is used to get values from input, select and textarea. Please check more info here: http://api.jquery.com/val/
Hey this code worked for me! But say I write, 1.2 in box 1 and 2.7 in box 2 my total comes out 3. How do I write the code to give me the total 3.9 and include the decimal in the total box.
Nvm I found the solution using.
var item1 = parseFloat(Appery('TimeBilledTaskA').val());
var item2 = parseFloat(Appery('TimeBilledTaskB').val());
var item3 = parseFloat(Appery('TimeBilledTaskC').val());
var item4 = parseFloat(Appery('TimeBilledTaskD').val());
var item5 = parseFloat(Appery('TimeBilledTaskE').val());
var item6 = parseFloat(Appery('TimeBilledTaskF').val());
var item7 = parseFloat(Appery('TimeBilledTaskG').val());
var item8 = parseFloat(Appery('TimeBilledTaskH').val());
var result = item1 + item2 + item3 + item4 + item5 + item6 + item7 + item8;
Appery('TotalSum').text(result);