Solved

ADOBE FORM-CALCULATION FORMULA

Posted on 2008-10-13
3
3,241 Views
Last Modified: 2008-10-15
I have a Form that I need a calculated field in, but I don't know the scripting enough to do what I want.  Here is the formula in lamans terms.

((Field 2) - (Field 1) )/(Field 1)

This would then be a % output.
Thanks
0
Comment
Question by:nursecore
  • 2
3 Comments
 
LVL 6

Expert Comment

by:gxp071
ID: 22722449

add the code below to the "Custom Calculation script:" of the textFeild calcuation tab.

Code below also rounds to 2 dp.  its basically just Javascript, read these for more details on using javascript in a pdf.  I'm just looking up how to append the '%' symbol but probably just a matter of adding at the end..


event.value = roundNumber( ( this.getField('Field 2').value - this.getField('Field 1').value  )  / this.getField('Field 1').value , 2 );
 

function roundNumber(num, dec) {

	var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);

	return result;

}

Open in new window

0
 
LVL 6

Accepted Solution

by:
gxp071 earned 500 total points
ID: 22722470
yep just wack the % string on the end.  sorry left off the link last time

http://www.adobe.com/devnet/acrobat/javascript.html 


event.value = roundNumber( ( this.getField('Field 2').value - this.getField('Field 1').value  )  / this.getField('Field 1').value , 2 ) + '%';
 

function roundNumber(num, dec) {

        var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);

        return result;

}

Open in new window

0
 

Author Comment

by:nursecore
ID: 22723384
Thanks this solution worked great!!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
This video teaches users how to migrate an existing Wordpress website to a new domain.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now