PDF Editing Issues

Fix Acrobat JavaScript Pages Not Deleting When a Checkbox Is Cleared

Camila MilosovichCamila Milosovich Nov 25, 2026 870 views

Question details

Determine why an Acrobat JavaScript function does not delete spawned template pages when a checkbox is cleared.

Fix Acrobat JavaScript Pages Not Deleting When a Checkbox Is Cleared
Product
Adobe Acrobat JavaScript
Device & OS
not provided
Scenario
A PDF form uses a checkbox to spawn multiple template pages and should remove them when the checkbox is cleared.
Observed behavior
The template pages are spawned when the checkbox is selected, but they remain after it is cleared.
Before you start

Open the PDF in Acrobat and locate the checkbox action, the page-spawning function, and the code that calls deletePages. Identify the marker field used to find the spawned pages and the checkbox's export value.

Solution 1Recommended

Check the Acrobat JavaScript console and page range

Use console output to find errors and verify the page numbers passed to deletePages.

1
Open the console

Open Acrobat's JavaScript console with Ctrl+J on Windows or Command+J on macOS, then select and clear the checkbox. Look for errors reported when the deletion code runs.

2
Log the calculated values

In the deletion function, add console.println statements immediately before deletePages, such as console.println('P19: ' + P19) and console.println('numPages: ' + this.numPages). Also log the calculated ending page number.

3
Verify the starting page

Check the value returned by getSpawnedPageNumber against the first spawned page. Inspect that helper function if it returns an unexpected value, and confirm that its marker field exists under the name the function expects.

4
Check the deletion range

Review the deletePages call and confirm that its start and end page numbers are valid, zero-based, and inclusive. The start must not exceed the end, and the end must be less than this.numPages.

5
Retest the checkbox

Clear the JavaScript console, select the checkbox to spawn the pages, and clear it again. Compare the new output with the actual spawned page range before changing the deletion logic.

Check the Acrobat JavaScript console and page range
Page numbering: Acrobat JavaScript uses zero-based page indexes: the first page is 0. A deletePages call also cannot remove every page in a document.
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 Microsoft Office files. Its format support helps make moving everyday documents easier, though it does not fix Acrobat JavaScript.

Open and review PDF documents alongside other filesCompatible with Microsoft Office formats including DOCX, XLSX, and PPTXUse a familiar interface for everyday document tasksWork in a lightweight office suite with free features
microsoft office alternative - wps office

Frequently Asked Questions

How do I see JavaScript errors in Acrobat?

Open the JavaScript console with Ctrl+J on Windows or Command+J on macOS, then reproduce the checkbox action and inspect the console output.

Why does my script not find the spawned page?

Check that the marker field exists on the spawned page and that getSpawnedPageNumber uses its actual field name. Log the helper's return value in the JavaScript console and compare it with the page's zero-based index.

Does every checked Acrobat checkbox have the value "Yes"?

No. The checked value depends on the checkbox's export value. Open the field's Properties in Prepare a Form and compare that value with the string used in the script.

What page numbers does deletePages use?

The deletePages method uses zero-based page indexes, and its start and end indexes are inclusive. Check that both are within the document's current page range before calling it.

Can WPS Office repair the Acrobat JavaScript function?

WPS Office does not fix Acrobat's JavaScript execution or form actions. Use Acrobat's form editor and JavaScript console to troubleshoot this function; WPS Office is an alternative for everyday PDF and Office document work.