PDF Editing Issues

Fix Checkbox JavaScript on Spawned PDF Pages in Adobe Acrobat

Algirdas JasaitisAlgirdas Jasaitis Nov 19, 2026 868 views

Question details

Make a checkbox script identify related fields on both the original PDF form page and pages spawned from a template.

Fix Checkbox JavaScript on Spawned PDF Pages in Adobe Acrobat
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A PDF template creates additional form pages whose field names have page and template prefixes.
Observed behavior
The checkbox script works on the original page but does not find the related image and text fields on spawned pages.
Before you start

Open the PDF in Adobe Acrobat and use Prepare a Form to inspect the checkbox and related field names on both the original and spawned pages. Confirm that spawned names follow a pattern such as P2.Template.FieldName.

Solution 1Recommended

Extract the spawned-page prefix from the checkbox field name

Use the triggering checkbox name to locate related fields on the same spawned page while retaining support for unprefixed original fields.

The example assumes spawned fields have two prefix components, such as P2.Template, followed by the original field name. If your field names use a different structure, adjust the prefix extraction to match.

1
Open the checkbox action

In Acrobat, open Prepare a Form, right-click the checkbox on the template, and select Properties. On the Actions tab, select the Mouse Up trigger and add or edit a Run a JavaScript action.

2
Add the prefix to field lookups

In the JavaScript editor, adapt the visibility logic to use the prefix from event.target.name. For example: var parts = event.target.name.split('.'); var prefix = parts.length > 2 ? parts[0] + '.' + parts[1] + '.' : ''; var imageField = this.getField(prefix + 'Image15_af_image'); var textField = this.getField(prefix + 'AskDetails15'); var show = event.target.value !== 'Off'; if (imageField) imageField.display = show ? display.visible : display.hidden; if (textField) textField.display = show ? display.visible : display.hidden;

3
Test both page types

Save the action, exit Prepare a Form, and toggle the checkbox on the original page and a newly spawned page. Confirm that each checkbox changes the image and text fields on its own page.

Extract the spawned-page prefix from the checkbox field name
Match your field names: Replace Image15_af_image and AskDetails15 with the exact unprefixed names of your related fields. The example shows them when the checkbox is checked; reverse the visibility values if your form needs the opposite behavior.
Free Microsoft Office alternative

Work with PDF and Office files in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with PDF and Office files. Its format compatibility helps you bring existing documents into your workflow, but it does not fix Acrobat's spawned-field JavaScript.

Open PDFs alongside your other documentsCompatible with Microsoft Word, Excel, and PowerPoint formats, including DOCX, XLSX, and PPTXUse a familiar interface to transition from Microsoft OfficeFree to use, with some advanced features requiring a subscription
microsoft office alternative - wps office

Frequently Asked Questions

Why does the script work on the original page but not the spawned page?

Acrobat can add a page and template prefix to spawned field names. A lookup such as this.getField('AskDetails15') will not find a field named P2.Template.AskDetails15 unless the prefix is included.

Where can I find the checkbox's JavaScript in Acrobat?

Open Prepare a Form, right-click the checkbox, and select Properties. On the Actions tab, look for a Run a JavaScript action under the relevant trigger, such as Mouse Up.

What happens if a related field name is incorrect?

this.getField() returns null when it cannot find the field. Check the full name in Prepare a Form and confirm that the script combines the correct prefix and unprefixed field name.

Will the example work if my field names contain additional periods?

Not necessarily. The example treats the first two components as the spawned-page prefix when there are more than two components. Inspect your original and spawned names and adjust the extraction logic if they use a different pattern.