Page 1 of 3
Calculating Fields
Posted: Sun Nov 24, 2013 10:22 pm
by Matthew6439702
I have been learning a lot and I understand some of the basics of javascript but debugging has been slow. Can I use the below script to get values then calculate a result?
function getTotal()
{
var adjustedProtein = proteinInput() + ServingsField();
How can I display result into a label or input field?
//display the result? I know this is wrong
document.getElementById('AdjPrtCalc').innerHTML =
"Total Protein Grams $"+adjustedProtein;
}
Calculating Fields
Posted: Sun Nov 24, 2013 10:35 pm
by Igor
Hello,
1, What exactly values do you want to calculate?
- You can use local storage variable. http://docs.appery.io/documentation/w...
Calculating Fields
Posted: Sun Nov 24, 2013 10:57 pm
by Matthew6439702
The values are multiplied by the users ServingsField() input.
function getTotal()
{
var adjustedProtein = proteinInput() * ServingsField();
If this script works I don't know how to return the result to a specific Input field
ie. 'AdjPrtCalc'.
function getTotal()
{
var adjustedProtein = proteinInput() * ServingsField();
getElement('AdjPrtCalc');
}
Is this the right format?
Calculating Fields
Posted: Sun Nov 24, 2013 11:02 pm
by Igor
You can save value to localStorage variable and bind the variable to a component. See link from previous response.
Calculating Fields
Posted: Sun Nov 24, 2013 11:22 pm
by Matthew6439702
I have gone through hours of tutorials watched video. I just was looking at the example but none of this makes sense. Outside of being critical to all responses I have read about calculations and returning results. I need application examples. "LocalStorage variables," what is that and the use for it. My input field is setting the value. I need to return a calculation. Script seems to be the easiest way. I understand some can be ran on the server. My calculations don't seem to be that complex. I want to call '$' a field and calculate the return. Writing the script in Appery is a little different than what I have learned.
I'm not calling HTML elements but Appery elements...this confuses me. If I could see the whole script and HTML maybe I could make more sense of how to input the javascript.
The examples I get online show examples of working with HTML not Appery. Theres an application gap I am missing.
Calculating Fields
Posted: Sun Nov 24, 2013 11:25 pm
by Matthew6439702
Can I just put an HTML box into the screen and create a custom form with calculations completely in HTML and javascript?
Calculating Fields
Posted: Sun Nov 24, 2013 11:36 pm
by Igor
Yes, you can use HTML component for HTML and JavaScript.
Try to start from this tutorial first: http://docs.appery.io/tutorials/build...
Calculating Fields
Posted: Mon Nov 25, 2013 1:05 am
by Matthew6439702
So I have been using the HTML element and it is so much easier to manipulate javascript, css and HTML. When mapping.....can I drag the html component to each request value then call it out with script to map the response so I can use the appery database?
Calculating Fields
Posted: Mon Nov 25, 2013 1:11 am
by maxkatz
As the HTML component can include any code, there is no way to expose attributes that you can use via mapping.
Calculating Fields
Posted: Mon Nov 25, 2013 1:21 am
by Matthew6439702
Using the HTML element allows me to calculate fields in javascript more easily. Actually I am lost how to do it otherwise using Appery. No script seems to be working and i can't debug it very fast because I can't see the entire source. I am lost on how appery works with the source code using js. The way I would write it for a normal html doc seems to be different with appery "run javascript." I can't find my values to elements then display them in other fields. I am missing something and like I said I have spent hours upon hours reading your tutorials. Most of the help I have recieved has been reading specific application questions people have asked. I don't need salesforce tutorials. Most of the tutorials I need are all cluttered up with Salesforce applications I want strictly appery.io tutorials with calculations to use appery database. I am frustrated cause I can write the javascript using html tags in the html component to do all my calculations but I can't make the run javascript to work when I invoke services. It's almost easier to build everything by scratch but I then have a problem accessing the appery database to create, update, query and so on.