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

Simple Calculation Script

Yes, it would have to be every combination. Something like this:

code
if (to == 'Inches') {
if (from == 'Feed'){
...
}
else if (from == 'Yards') {
...
}

}
else if (to=='Yards') {
if () {
...
}
else if () {
...
}
...
}
/code

wv.wilson75
Posts: 0
Joined: Fri Dec 30, 2011 2:53 am

Simple Calculation Script

Thanks. . . I am going to play around with this and see if I can make it work . . . I truly appreciate all your help on this.

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

Simple Calculation Script

You welcome.. glad to help.

wv.wilson75
Posts: 0
Joined: Fri Dec 30, 2011 2:53 am

Simple Calculation Script

So here is what I tried . . . now nothing is working. Can you look and see what I have done wrong here. I am sure it is obvious.

var input = Tiggr('baseunit').val();
var from = Tiggr('convertfrom').val();
var to = Tiggr('convertto').val();

if (from == 'Acres') {
if (to == 'Acres'){
var total = input * 0;
alert ( " ERROR: You are converting to the same unit of measurement! ");
}
else if (to == 'Poles / Perches / Rods'){
var total = input * 160;
alert (input + " acres equal "+ total + " Poles, Perches or Rods" );
}
else if (to == 'Square Feet') {
var total = input * 43560;
alert (input + " acres equal "+ total + " Square Feet" );
}

}

if (from == "Poles / Perches / Rods') {
if (to == 'Poles / Perches / Rods'){
var total = input * 0;
alert ( " ERROR: You are converting to the same unit of measurement! ");
}
if (to == 'Acres'){
var total = input / 160;
alert (input + " Poles, Perches or Rods equal "+ total + " Acres" );
}
else if (to == 'Square Feet') {
var total = input * 43560;
alert (input + " Poles, Perches or Rods equal "+ total + " Square Feet" );
}

}

if (from == "Square Feet') {
if (to == 'Square Feet'){
var total = input * 0;
alert ( " ERROR: You are converting to the same unit of measurement! ");
}
if (to == 'Acres'){
var total = input / 43560;
alert (input + " Square Feet equal "+ total + " Acres" );
}
else if (to == 'Poles / Perches / Rods') {
var total = input * 43560;
alert (input + " Square Feet "+ total + " Poles, Perches or Rods" );
}

}

wv.wilson75
Posts: 0
Joined: Fri Dec 30, 2011 2:53 am

Simple Calculation Script

Note that the conversion numbers are not correct. I just haven't done that yet. I also corrected the missing "Else" x 2

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

Simple Calculation Script

Try commenting out the last two if-blocks and see if the error is in the first one and so on. You can also use Chrome Development Tools or Firebug to see where the problem is.

wv.wilson75
Posts: 0
Joined: Fri Dec 30, 2011 2:53 am

Simple Calculation Script

Got it~ Thanks for the tip. I didn't know I could use firebug.

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

Simple Calculation Script

Yes, to debug the resulting app in browser.

Return to “Issues”