Solved

Posted on 2008-10-13
Medium Priority
3,252 Views
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
Question by:nursecore
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 2

LVL 6

Expert Comment

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;
}
``````
0

LVL 6

Accepted Solution

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

``````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;
}
``````
0

Author Comment

ID: 22723384
Thanks this solution worked great!!
0

## Featured Post

Question has a verified solution.

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

When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
###### Suggested Courses
Course of the Month15 days, 5 hours left to enroll