Skip to main content
Participant
February 14, 2025
Question

Adobe Acrobat Does Not Show Selection

  • February 14, 2025
  • 2 replies
  • 541 views

I am having issues with an Adobe Acrobat pdf. The JavaScript that I have is working correctly for what I am doing which is making a dynamic D&D 5e Character Sheet. I have checked the spelling and it's all correct. There's no issues with punctuation, or capitals either. Everything is as it should be.

 

The way this is supposed to work is when I select a Class from the Class1 drop-down, the appropriate checkboxes should be checked (marked true). When I enter the level of the class, the SubClass drop-down shows the available sub classes if the level is high enough. If the sub class chosen adds more proficiencies, those checkboxes and/or proficiency text field displays the correct items the character is proficient with. If the character is a multi-class character and selects another class after the primary class chosen, the script adds the new proficiencies based on the rules in the 2014 Player's Handbook, Tasha's and Xanathar's books.

 

Every single class works as intended based on this script I'm about to show you. All except the Cleric and its Subclasses. When I select Cleric or its subclasses that add proficiencies no change on the character sheet occurs. The proficiency checkboxes remain blank. If I choose another class first in the Class dropdown box, let's say I select Barbarian, it highlights correctly; but if I then change it from Barbarian to Cleric, the Barbrian proficiency checkboxes and text field remain the same as showing the Barbarian proficiencies. I have run debugging tests and it shows that the form is recognizing Cleric and the SubClasses and its level as intended. It just refuses to turn on the correct proficiency checkboxes. 

 

Here is the script and I have attached the document I am working on. What is going wrong?


Correction: Apparently I can't just copy/paste a JavaScript here, so please see the script under the Calculation Field in the Proficiency text field on the second page. The drop down lists are at the top of the first page. 

2 replies

Thom Parker
Community Expert
Community Expert
February 14, 2025

There are errors displayed in the Console Window for all selections.  The "Cleric" selection has the additional error that Nesa pointed out. But you should always check the console first and fix those errors. 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
IcosiolAuthor
Participant
February 14, 2025

As you can probably tell I am not educated on the ways of JavaScript, and am using AI to try and get what I want. I just used simple script to get it working roughly the way I wanted. Now with AI I am trying to unlock all the options JavaScript can do. 

When you say Console Window I am not entirely sure what you're talking about.

Thom Parker
Community Expert
Community Expert
February 14, 2025

The Console is displayed by pressing Ctrl-J.

See this video:

https://www.pdfscripting.com/public/images/video/AcroJSIntro/AcroJSIntro_ConsoleWindow.cfm

 

AI will screw you. It is the worst possible way to write a script.  All it does is cobble together random crap from the web. Whereas the helpful experts on this forum, and others, actually know what they are doing and test code before providing it. 

Don't ever ask someone here to fix crap from an AI. 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Nesa Nurani
Community Expert
Community Expert
February 14, 2025

'includes' will not work in Acrobat, use indexOf()

IcosiolAuthor
Participant
February 14, 2025

Thank you. As soon as I get home I will try that.