Page 2 of 3

Calculating Fields

Posted: Mon Nov 25, 2013 1:25 am
by maxkatz

You can read any page inputs with jQuery or using the Appery(..) function. It's actually pretty simple. You will find examples here: http://docs.appery.io/javascript-api/


Calculating Fields

Posted: Mon Nov 25, 2013 3:42 am
by Matthew6439702

I have gone thru all your examples tutorials. I think what I need to see is the backend. Is there a way to see the HTML or Javascript or CSS and edit there?


Calculating Fields

Posted: Mon Nov 25, 2013 4:13 am
by maxkatz

You can view the source in Source tab.

You can also edit there but do keep in mind that if you make changes to the page code, the visual builder will not be longer updated (you can a always roll back the changes)


Calculating Fields

Posted: Mon Nov 25, 2013 8:00 am
by Matthew6439702

Thank you


Calculating Fields

Posted: Mon Nov 25, 2013 8:19 am
by Matthew6439702

//This
var x = Appery('input1').val();
var y = Appery('input2').val();
var z = (x) + (y);

var res = z;
alert (res);

//instead of this
var x = $("input1");
var y = $("input2");
var z = x + y;

var res = z;
alert (res);

This is what I have been stuck on

var z = x + y only connects the two strings. I spent quite a while trying to figure out that it had to be (x)+(y) to get the sum. I am catching on to the Appery instead of $. Just all the examples I have been learning are slightly different than what works on Appery. You guys are used to it I am sure but I keep putting } at the end of functions and it keeps the script from working then I look back and realize what happened.


Calculating Fields

Posted: Mon Nov 25, 2013 9:06 am
by Kateryna Grynko

Hi Matthew,

Use function 'parseInt' to convert string to int:prevar num = parseInt("10");/pre
Variable 'num' value will equal 10 (int). You can then sum it.

Also you should use preAppery('input1').val();/preinstead of:pre$("input1")/preas $("input1") returns null (you use sample by 'input1' tag, not by ID or by name).


Calculating Fields

Posted: Thu Dec 05, 2013 1:27 am
by Matthew6439702

I have figured out that my problem has to do with calling the value of the field in a generated list. The below script works outside of a generated list. I used a collapse box to fill in data from my database. I can call the value of every input field outside of the generated list but when I put the grid back in the collapse box I can't seem to find the value of the selected collapse block of my generated list. How can I find the input field and it's value that ties to the collapse block I expand/choose?

var servinput= Appery('ServingsInput');
var num = servinput.val();
var protein = Appery('Protein');
var num1 = protein.val();
var prtAdjust = num * num1;
var getval = Appery('prtCalc');
getval.val(prtAdjust);

var fat = Appery('Fat');
var num2 = fat.val();
var fatAdjust = num * num2;
var getval2 = Appery ('fatCalc');
getval2.val(fatAdjust);

var carb = Appery ('Carb');
var num3 = carb.val();
var carbAdjust = num * num3;
var getval3 = Appery ('carbCalc');
getval3.val(carbAdjust);

var servWt = Appery ('ServWt');
var num4 = servWt.val();
var srvwtAdjust = num * num4;
var getval4 = Appery ('ServWtAdj');
getval4.val(srvwtAdjust);

var servMeasure = Appery ('ServMeasure');
var num5 = servMeasure.val();
var srvmsrAdjust = num * num5;
var getval5 = Appery ('ServMeasureAdj');
getval5.val(srvmsrAdjust);

Image


Calculating Fields

Posted: Thu Dec 05, 2013 9:48 am
by Maryna Brodina

Hello! Could you give us your public app link or share app with a href="mailto:support@appery.io" rel="nofollow"support@appery.io/a?


Calculating Fields

Posted: Thu Dec 05, 2013 2:03 pm
by Matthew6439702

Calculating Fields

Posted: Thu Dec 05, 2013 2:44 pm
by Maryna Brodina

Thank you! What are the steps to reproduce?