Page 1 of 1

Newby, need javascript for calculations

Posted: Wed Feb 20, 2013 2:24 am
by Skye Dunning

Hi, I'm completely new to app development. I was able to create the simple beginning tutorial and it's pretty similar to what I want. The tutorial has a text entry on page one that displays in page two:

var input = Tiggzi('Input').val();
localStorage.setItem('text', input);
Tiggzi.navigateTo('Result', {});

To start with, what I need is the javascript to replace the middle line that would do a calculation and put it on page two instead::

var input = Tiggzi('SquareFeet').val();
var total = input * .06;
Tiggzi.navigateTo('Result', {});

This will progress on to some "if, then" type calculations, but that's as complicated as it gets.

Is there a good reference for writing spreadsheet type javascript calculations without getting buried under javascript everything?


Newby, need javascript for calculations

Posted: Wed Feb 20, 2013 4:32 am
by maxkatz

[quote:]
Is there a good reference for writing spreadsheet type javascript calculations without getting buried under javascript everything?
[/quote]
I'm not aware of guides that do specifically that. There are many good JavaScript resources available on the Internet today, but they will be all JavaScript.


Newby, need javascript for calculations

Posted: Wed Feb 20, 2013 2:26 pm
by Skye Dunning

Can anyone help me with a snippet of code here? Something that would take numbers in input box 1, multiply that by, say, .02 & display it on the results page? I think from there I might be able to extrapolate.


Newby, need javascript for calculations

Posted: Wed Feb 20, 2013 2:29 pm
by maxkatz

You can use the API here to read values from input components: http://docs.tiggzi.com/javascript-api/.

Once you get the values, you can do something like this:

var total = num1 * 0.02;

I'd really recommend to try some basic JavaScript tutorials before you attempt to build a mobile app.