3 Replies Latest reply on Aug 8, 2012 2:03 PM by a.n.bentz

# Custom Calculation for two percentage fields

Hello

Right off the bat, thank you for taking the time to read my question. I am creating a form that is fillable and calculable within Adobe X Standard. I have two fields that are percentages. Adobe's percentage standard is to multiple whatever number you put into the field by 100 and make that the percentage. I wrote a custom script to divide the number by 100, so if I want 1% I can put 1 in the field instead of 0.01. However, I have two of these fields, and now when I put 1% in the first field and then 2% in the second field, it divides the first field by 100 again so that it reads 0.01%.

This is the formula I'm using to divide the value by 100:

if(event.value)event.value /=100;

This script is in both boxes, which I have labeled as V3 and V12. Do I need to get more specific with the script? Is there a way to keep the value of V12 from affecting the value of V3 and vice versa?

Thank you,

Amanda

• ###### 1. Re: Custom Calculation for two percentage fields

You do realize that Acrobat updates all calculations when a field used in a calculation is updated. You should be aware that for the "Percentage" format is used the value of the field is the decimal value, like 0.01, and the display is formatted to show the decimal as a percentage, 1%.

I would just learn to live with the way Acrobat/Reader works, unless you want to write more JavaScript.

• ###### 2. Re: Custom Calculation for two percentage fields

Hello,

Thank you for your time. I thought at first it was just showing the number as 0.01 and then when I finished editing the field, it would display the number as 1%. However, the value displayed is 0.01%.

I don't know how to upload screen shots into this forum or I would show you what is happening. But basically these two fields are not related to each other. They are not calculated together for any reason or are part of the same calculation. I can type 1 into the first field and it will read 1%. When I type 1 into the second percent field it will read 1%, but it will cause the first field to display 0.01%. I know it's confusing without the visual aids, I'm sorry for that. But that is the best way I can describe what is happening.

And normally, I would live with it. However, this form is going to be used by more people than myself and I'm trying to make it as simple as possible for the user, even if it is not simple for me. :-)

But thanks for the advice. I will continue to try to see if something else will work before I quit. :-) Unfortuantely I am stuck with Adobe, as our new operating system only recognizes Word Documents and PDFs.

• ###### 3. Re: Custom Calculation for two percentage fields

I figured it out! Simple mistake. I was placing the script in the Custom Calculate section, when I should have been putting it in the Custom Validation section. Silly me.

I do have one more question. I think my script may be wrong, but here is the scenario:

I have two fields V1 and V3 that are multiplied together to come up with V4 value. However, V3 will not always be filled out. I want V4 to still hold a value if V3 is blank. Right now what happens if V3 is blank, then V4 stays blank, even after I have put a number there. I know that I need and if, then statement, but whatever I try to write myself or piece together from other forums is not working.

Here is the script I have thus far:

var v1=+getField("V1").value;

var v2=+getField("V3").value;

if(V1.toString()!=""&&V3.toString!="")

event.value=V1*V3

My problem is I can fill V4 with a value and it will stay, however it will not run the calculation if V3 is filled. I know I'm missing something, but I'm not that experienced with writing script (I'm learning though!). I appreciate all of your help.

Thank you,

Amanda