These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Form Calculation Issues

todd0168
Registered: Oct 1 2009
Posts: 13
Answered

Ok I am having two separate issues with my form calculations. Firstly, when trying to use the simple calculation option and just pick the fields, I can pick the fields I want but when I hit ok the fields don't populate into the box and no calculation is performed.

My second issue is basically if there is no fix for the pick option, how can I script in a function to pick the minimum value out of three fields.

Also, can someone show me or link me to a script that will perform subtraction but display 0 if the value is less than 0?

Thanks in advance.

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Have you tried to repair your Acrobat installation?

What OS and version of Acrobat are you using?

You might be able to use the "Custom calculation script".

George Kaiser

todd0168
Registered: Oct 1 2009
Posts: 13
Windows XP Pro

Acrobat Pro 9.0

And I know I could use a custom script, that's why I asked for one.

Haven't tried the repair, will do that now.

/edit - ok have done the repair and still can't get the pick boxes to stick in the calculation.
suewhitehead
Registered: Jun 3 2008
Posts: 232
here is how to put the script in for a minimum


//place script on Text3 field on
//calculate tab,custom calculation script
//all three fields should be set to format:number

var f = this.getField("Text1").value
var g = this.getField("Text2").value
event.value = Math.min(f,g)
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
If you are going to determine the minimum of a series of values, you might want to consider writing a document level function that will accept a variable number of parameter and return the minimum of the group.

function Min(fNum1, fNum2) {// return the minimum value of 2 passed numbersif(isNaN(fNum1) | isNaN(fNum2) ){// received non-numeric inputapp.alert('Minimum function accepts only numeric values');}return Math.min(fNum1, fNum2);} function GetMin() {// return the minimum number from the passed arguments to the functionvar fMin = arguments[0];for (i = 1; i < arguments.length; i++) {fMin = Min(fMin, arguments[i]);}return fMin;} event.value = GetMin(this.getField("Text.0").value,this.getField("Text.1").value,this.getField("Text.2").value,this.getField("Text.3").value);

George Kaiser

todd0168
Registered: Oct 1 2009
Posts: 13
suewhitehead wrote:
here is how to put the script in for a minimum//place script on Text3 field on
//calculate tab,custom calculation script
//all three fields should be set to format:number

var f = this.getField("Text1").value
var g = this.getField("Text2").value
event.value = Math.min(f,g)
If I need to pick from three values can I just add another line:

var f = this.getField("Text1").value
var g = this.getField("Text2").value
var h = this.getField("Text3").value
event.value = Math.min(f,g,h)

Will that work?

/edit - ok that worked so thanks a bunch.