Solved

ADOBE FORM-CALCULATION FORMULA

Posted on 2008-10-13
3
3,245 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
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…

772 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