PDF Editing Issues

How to Set a PDF Text Field to Zero When Checkbox is Unchecked

John WilsonJohn Wilson Oct 28, 2026 869 views

Question details

The user needs to configure a PDF form so that a specific text field automatically updates to 0 when an associated checkbox is cleared, and returns to 100 when the checkbox is selected.

How to Set a PDF Text Field to Zero When a Checkbox Is Unchecked
Product
PDF
Device & OS
not provided
Scenario
Designing an interactive PDF form where a numerical text field's value dynamically depends on the toggled state of a checkbox.
Observed behavior
The text field correctly displays 100 when the checkbox is selected, but fails to revert to 0 when the checkbox is unchecked because the correct condition check is missing.
Before you start

Ensure you are using a PDF editor that supports form editing and JavaScript execution. Additionally, verify the exact name of your checkbox field under its properties, as script references are strictly case-sensitive.

Solution 1Recommended

Apply a Custom Calculation Script to the Text Field

Use a simple JavaScript conditional statement in the text field's calculate properties to check the value of the checkbox.

Because the default value of an unchecked checkbox in PDF forms is "Off", you can use a custom script to test for this specific string. When the value is "Off", the script sets the text field to zero; otherwise, it assigns 100.

1
Open Field Properties

Open your PDF in form editing mode. Right-click the text field that you want to display the number, and select 'Properties'.

2
Navigate to the Calculate Tab

In the Text Field Properties dialog box, click on the 'Calculate' tab to view calculation options.

3
Enter the Custom Script

Select 'Custom calculation script' and click the 'Edit' button. Enter the following script: event.value = (this.getField("CheckBox36").valueAsString == "Off") ? 0 : 100;

4
Adjust the Field Name

Replace 'CheckBox36' in the script with the exact name of your checkbox. Click 'OK' to save the script.

5
Test the Form

Close the form editing mode and toggle the checkbox to confirm the text field updates to 0 when unchecked and 100 when checked.

Apply a Custom Calculation Script to the Text Field
Case Sensitivity: Make sure the checkbox name in your script matches the actual field name exactly, including capitalization. 'checkbox36' and 'CheckBox36' are treated as two different fields.
Advanced PDF Form Editing

Create Interactive PDF Forms with WPS Office

WPS Office offers a robust PDF editor that allows you to seamlessly add interactive form elements like checkboxes and text fields, format your document, and manage PDF data without hassle.

  1. 1. Open Your PDF Document: Launch WPS Office and open your PDF file using the built-in PDF reader and editor.
  2. 2. Access Form Editing Tools: Navigate to the 'Form' tab on the top ribbon to access interactive form controls.
  3. 3. Add Form Elements: Click on 'Text Field' or 'Check Box' and drag on the document to place your form elements.
  4. 4. Customize Field Properties: Double-click any form field to open the properties panel and configure its appearance, format, and interactions.
Easily insert and customize checkboxes, text fields, and dropdowns.Highly compatible with standard PDF document formats and form properties.All-in-one suite to view, edit, annotate, convert, and manage PDFs effortlessly.
microsoft office alternative - wps office

Frequently Asked Questions

Why is my PDF calculation script not updating the text field?

This usually happens due to a typo or incorrect casing in the field name. PDF JavaScript is strictly case-sensitive. Ensure that the name specified in this.getField('FieldName') perfectly matches the actual property name of the checkbox.

How do I find the exact name of my PDF checkbox?

Enter form editing mode, right-click the checkbox, and select 'Properties'. Under the 'General' tab, you will see the exact 'Name' of the field. Copy this name to use in your calculation scripts.

What is the default value of an unchecked checkbox in standard PDF forms?

By default, when a checkbox is cleared or unchecked in a standard PDF form, its value is interpreted as the string "Off". That is why checking for "Off" in a calculation script accurately determines if it is unchecked.

Can I hide the text field entirely when the checkbox is unchecked instead of showing zero?

Yes. Instead of changing event.value in a calculation script, you would add a Mouse Up action to the checkbox itself that toggles the text field's display property (e.g., this.getField('TextFieldName').display = display.hidden).