Hi,
I'm trying to build a form for my lanscaping business. Here is the form:
http://theoutcasts.net/bort/landscaping_wrtbl1.pdf
(it's set up for addition right now to show another confusion I have)
What I'm trying to get it to do is divide the "Number of Visits" by the "Balance" and display that result in the "Annual" field.
It will do any other arithmetic operation OTHER than divide. As soon as I have the script make it perform division I get "the value entered does not match the format of the field [Annual]" as described in this thread:
http://acrobatusers.com/forum/forms-acrobat/division-text-field-properties-help
The other issue I'm a bit confused on you can cause to happen on the live form I linked above. Place 100 in the "Total" field. Then place 2 in the "Number of Visits" field. Although the script is:
var v1 = parseFloat(getField("Balance").value*1); var v2 = parseFloat(getField("nov").value*1); <br /> event.value = v1+v2;
(Fields are named accordingly. "Balance" is the balance field name, "nov" is the Number of Visits field name, "Annual" is the annual field name, and "total" is the Total field name.)
So, to me, according to the script, it should display the result of 100+2 as 102. But for some reason the addition operation I'm telling it to do is actually subtracting and the result displayed in the Annual field ends up being 98. I'm assuming it's doing that because one of the numbers is a negative integer. But...which one? I'm entering all of the information as positive integers. The only negative I can get it to show is the one that ends up in the Annual field. What the...???
How do you fix the positive/negative thing so it performs the math as it should?
And [b]how do I write the correct script so that Balance is divided by the value in 'nov'?[/b]
I've tried several scripts and have asked for help from several java scripter friends over the last few days and none of us have been successful in getting it to divide or have the result of adding two positive integers end up being a positive number, as it should.
I'm praying someone here can help me so I can get this working.
You've set up the balance field so that it's a negative value if the deposit is less than the total. So your script should actually subtract v2. Also, to get the field value as a number, you can just do this:
// Get the field value as a number
var v1 = +getField("Balance").value;