Use an Adobe Acrobat Checkbox to Fill PDF Fields with N/A
Question details
The user wants a PDF form checkbox to insert N/A into several fields when selected and clear them when deselected.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A PDF form has multiple text fields that can be marked not applicable using one checkbox.
- Observed behavior
- Selecting the checkbox should set the designated fields to N/A; deselecting it should clear them.
Open the PDF in a version of Adobe Acrobat that supports editing form fields, and check the exact names of the text fields in Prepare a Form. The script below replaces existing values in those fields and clears them when the checkbox is deselected.
Add a Mouse Up JavaScript action to the checkbox
Use this method to control several named text fields from one Acrobat form checkbox.
In Adobe Acrobat, open the PDF and choose All tools > Prepare a form. Add a checkbox if the form does not already have one.
Right-click the checkbox, select Properties, and open the Actions tab. Set Select Trigger to Mouse Up and Select Action to Run a JavaScript, then click Add.
Paste the following script into the JavaScript editor, replacing Text1, Text2, and Text3 with the exact names of your form fields: if (event.target.value == "Off") { this.getField("Text1").value = ""; this.getField("Text2").value = ""; this.getField("Text3").value = ""; } else { this.getField("Text1").value = "N/A"; this.getField("Text2").value = "N/A"; this.getField("Text3").value = "N/A"; }
Click OK to save the action, close the checkbox properties, and save the PDF. Exit form editing or use Preview, then select and deselect the checkbox to verify that the fields fill and clear.

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. It can help you work with existing documents, but it does not replace the Acrobat JavaScript setup described above; check your PDF viewer’s script support before distributing the form.

Frequently Asked Questions
How do I find the names of the PDF text fields?
In Acrobat, choose All tools > Prepare a form, then open a field’s Properties and check its name on the General tab. Use that exact name in each getField call.
Will the script leave existing field entries untouched?
No. Selecting the checkbox replaces the contents of every listed field with N/A, and deselecting it clears those fields. Use a different script if existing entries must be preserved.
Why does the checkbox work in Acrobat but not in another PDF viewer?
The other viewer may not support Acrobat JavaScript or may have JavaScript disabled. Test the saved form in each viewer your recipients will use.
Can I control more than three fields with the checkbox?
Yes. In the checkbox’s Mouse Up JavaScript action, add a getField line for each additional field in both branches: set it to an empty string in the Off branch and to N/A in the other branch.




