Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Cant get Javascript to execute

New Here ,
Apr 11, 2017 Apr 11, 2017

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.

TOPICS
Acrobat SDK and JavaScript , Windows
385
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 11, 2017 Apr 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;

Translate
Community Expert ,
Apr 11, 2017 Apr 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 11, 2017 Apr 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 11, 2017 Apr 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;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 11, 2017 Apr 11, 2017
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines