Skip to main content
Saher Naji
Inspiring
December 20, 2022
Answered

Java Scrip code to refresh the existing codes

  • December 20, 2022
  • 3 replies
  • 1887 views

I have several pdf fillable forms, and they contain javascript code.
When sent it to users using Adobe Acrobat on (Mac), these codes don't work!;
When sent it to users using Adobe Acrobat on (Windows), these codes work.
If there is a solution to make the code work perfectly in a Mac environment, that would be great.
But I think this is difficult, and because these forms, in the end, will be filled in, and then returned to the sender, who has a Windows system is there a (document-level-code) or a button code, to make the form (that the Mac users send) to refrest its code as soon as it is received?

Because when I receive the file some fields are empty, so I have to press again on check boxes, or re-enter the data again to make the code works.

I tried this code in the document level, but it did not work:

 

calculateNow()

 

In my form I have some calculations and this code:

 

this.getField("a_1").checkThisBox(0, (event.value == 3));
this.getField("a_2").checkThisBox(0, (3 < event.value) && (event.value < 6 ));
this.getField("a_3").checkThisBox(0, (event.value == 6));
this.getField("a_4").checkThisBox(0, (6 < event.value) && (event.value < 9 ));
this.getField("a_5").checkThisBox(0, (event.value == 9));
this.getField("a_6").checkThisBox(0, (9 < event.value) && (event.value < 11 ));
this.getField("a_7").checkThisBox(0, (event.value == 11));
this.getField("a_8").checkThisBox(0, (11 < event.value) && (event.value < 14 ));
this.getField("a_9").checkThisBox(0, (event.value == 14));
this.getField("a_10").checkThisBox(0, (14 < event.value) && (event.value < 17 ));
this.getField("a_11").checkThisBox(0, (event.value == 17));
this.getField("a_12").checkThisBox(0, (17 < event.value) && (event.value < 19 ));
this.getField("a_13").checkThisBox(0, (event.value >= 19));

 

 

Note: Some text-fields contain both codes and calculations (equations) at the same time

 

THANK YOU♥


Cheers,
Saher

This topic has been closed for replies.
Correct answer Bernd Alheit

Custom validation script


This will work in Acrobat Reader and Adobe Acrobat on Windows or Mac.

3 replies

Saher Naji
Inspiring
December 28, 2022

I found this answer:

 

I did not know that there is a difference between iOS and macOS regarding Adobe Reader.

So the problem is that the forms fillied in using Adobe Acrobat installed on iOS (iPad) or (iPhone), then the user sends the forms again to me, the JavaScript codes remain, but it seems frozen, so I have to click on some checkboxes to force the codes to run.
I did not test it on macOS yet, but I think it will work

 

So is there a code which I can run it using a button to refresh the codes and calculations again in my Windows system?

Legend
December 21, 2022

Acrobat JavaScript is the same on Mac. Have you tested it yourself on a Mac?

A common problem on Mac is that users open in the system app "Preview" rather than Acrobat. Ask for a screen shot of the complete screen including menu bar to check this. The app name is at top left.

Saher Naji
Inspiring
December 21, 2022

In fact I did not test it myself, that's a good point, gonna ask them

Bernd Alheit
Community Expert
Community Expert
December 20, 2022

What calculations does you use?

Saher Naji
Inspiring
December 20, 2022

 

Very short, Picking fields to sum them

Bernd Alheit
Community Expert
Community Expert
December 21, 2022

Where does you use the posted script?