Skip to main content
wesleyt70335991
Participant
April 11, 2017
Answered

Cant get Javascript to execute

  • April 11, 2017
  • 2 replies
  • 453 views

In Acrobat Pro 9, Field I, Properties, Actions tab, execute on Mouse up, entered the following javaScript:

if (H<3000){
I=3000
} else { I=H}

Field H is a calculated value.

I don't get any syntax errors, but when data is entered into the PDF, silently does not run and I get no value returned.  I have tried variations of the string with the same results.  Can someone please help.  Thanks.

This topic has been closed for replies.
Correct answer try67

Use this code as the custom calculation script of the "I" field:

var h = Number(this.getField("H").value);

if (h<3000) event.value = 3000;

else event.value = h;

2 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
April 11, 2017

Use this code as the custom calculation script of the "I" field:

var h = Number(this.getField("H").value);

if (h<3000) event.value = 3000;

else event.value = h;

wesleyt70335991
Participant
April 11, 2017

Thank you very much.  Tested it a few ways and appears to work fine. 

Joel Geraci
Community Expert
Community Expert
April 11, 2017

Your code is probably running just fine, it just doesn't appear to do anything that modifies the PDF in a way that you'd notice. There's not enough detail here to say for sure though. What are your actual field names?

wesleyt70335991
Participant
April 11, 2017

Actual field names are "I" and "H".  Keeping it simple.  Field "H" is a field calculated by acrobat using simple field notation and correctly executes.  Field I is a field that I want to either mirror field "H", or if the value of Field "H" is below 3000, then to have the returned value of Field "H" be 3000 (my minimum acceptable value ).  Hope this helps you help me.  Thanks.