Matthew6439702
Posts: 0
Joined: Sun Nov 24, 2013 1:10 am

Calculating Fields

  1. 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();

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

      }

Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

Calculating Fields

Hello,

1, What exactly values do you want to calculate?

  1. You can use local storage variable. http://docs.appery.io/documentation/w...
Matthew6439702
Posts: 0
Joined: Sun Nov 24, 2013 1:10 am

Calculating Fields

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?

Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

Calculating Fields

You can save value to localStorage variable and bind the variable to a component. See link from previous response.

Matthew6439702
Posts: 0
Joined: Sun Nov 24, 2013 1:10 am

Calculating Fields

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.

Matthew6439702
Posts: 0
Joined: Sun Nov 24, 2013 1:10 am

Calculating Fields

Can I just put an HTML box into the screen and create a custom form with calculations completely in HTML and javascript?

Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

Calculating Fields

Yes, you can use HTML component for HTML and JavaScript.
Try to start from this tutorial first: http://docs.appery.io/tutorials/build...

Matthew6439702
Posts: 0
Joined: Sun Nov 24, 2013 1:10 am

Calculating Fields

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?

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Calculating Fields

As the HTML component can include any code, there is no way to expose attributes that you can use via mapping.

Matthew6439702
Posts: 0
Joined: Sun Nov 24, 2013 1:10 am

Calculating Fields

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.

Return to “Issues”