Copy link to clipboard
Copied
I am computing a value of a system we are auditing. The field is CashValue. It is calulating correctly except that I want to set a minimum value of 1000. What do I need to change? Here is the code that Adobe generated.
//<AcroForm>
//<ACRO_source>CashValue:Calculate</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:CashValue:Calculate ***********/
/** BVCALC (1-Discount)*Average EVCALC **/event.value=(1-AFMakeNumber(getField("Discount").value))*AFMakeNumber(getField("Average").value)
//</ACRO_script>
//</AcroForm>
Copy link to clipboard
Copied
Let me see if I have this correct: You want to calculate the field by multiplying Discount and Average, and if the result is less than 1000, use 1000 as the calculated value. Is that correct? If so, you need to switch to a JavaScript calculation script. The simple field calculation will not be able to do that. Try the following script:
var val = Number(this.getField("Discount").value) * Number(this.getField("Average").value);
if (val < 1000) {
event.value = 1000;
}
else {
event.value = val;
}
Copy link to clipboard
Copied
Thanks for the help.