How to Update and Remove Combo Box Text via Acrobat JavaScript
Question details
The user needs to correctly update a shared text field based on a combo box selection using PDF JavaScript, ensuring old strings are removed and new selections are committed immediately.

- Product
- Adobe Acrobat PDF Forms
- Device & OS
- not provided
- Scenario
- Creating or editing an interactive PDF form where a drop-down combo box dynamically updates another text field.
- Observed behavior
- The current script appends new text while leaving previous proficiency strings in place, and it requires the selected value to be manually committed again.
Before modifying your PDF form scripts, ensure you have a backup of the original document and access to a PDF editor with advanced form properties and JavaScript console support.
Rebuild Target Text Strings Using event.change and event.willCommit
Update your JavaScript to read the pending selection and rebuild the target field dynamically, while enabling the drop-down to commit values instantly.
Continually appending text to a target field causes stale strings to remain when a user changes their combo box selection. By rebuilding the string from scratch and reading the pending event state, the field updates cleanly.
Right-click your drop-down combo box, select 'Properties', navigate to the 'Options' tab, and check the 'Commit selected value immediately' box.
Update your custom script to use the `event.change` property. This allows the script to accurately read the pending selection before it becomes final.
Wrap your field update logic inside an `if (event.willCommit)` condition to ensure the target text field only updates when the user finalizes their selection.
Instead of appending the new proficiency string to the existing value, program the script to clear the target field and completely rebuild it using the newly selected value to prevent lingering text.

Create and Edit PDF Forms with WPS Office
WPS Office provides a comprehensive PDF toolkit that allows you to easily create, edit, and manage interactive forms without always needing complex JavaScript coding for everyday tasks.
- 1. Open the PDF Document: Launch WPS Office and open your existing PDF file or create a new one.
- 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to reveal the interactive form toolkit.
- 3. Insert Form Controls: Select the desired controls, such as Text Fields, Checkboxes, or Combo Boxes, and drag them onto your document page.
- 4. Edit Properties: Double-click the added fields to customize their appearance, options, and behaviors, then save your interactive PDF.

Frequently Asked Questions
Why does my combo box selection keep appending text instead of replacing it?
This happens if your JavaScript is programmed to add the new string to the existing field value (e.g., using +=). To fix this, change the script to overwrite or rebuild the target text field entirely based on the new selection.
How do I make a PDF drop-down field commit instantly?
Open the combo box properties, go to the 'Options' tab, and check the 'Commit selected value immediately' checkbox. This forces the form to recognize the selection without requiring the user to click elsewhere.
What is the purpose of event.willCommit in PDF scripts?
The `event.willCommit` property is a boolean used in keystroke scripts to determine if a value is in the process of being saved to the field. It helps ensure your script only triggers secondary updates when the user's primary input is finalized.




