PDF Editing Issues

How to Update and Remove Combo Box Text via Acrobat JavaScript

Emma BrownEmma Brown Nov 5, 2026 869 views

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.

How to Update and Remove Combo Box Text Using Acrobat JavaScript
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 you start

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.

Solution 1Recommended

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.

1
Enable immediate commit

Right-click your drop-down combo box, select 'Properties', navigate to the 'Options' tab, and check the 'Commit selected value immediately' box.

2
Read pending selections

Update your custom script to use the `event.change` property. This allows the script to accurately read the pending selection before it becomes final.

3
Verify the commit state

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.

4
Rebuild the target value

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.

Rebuild Target Text Strings Using event.change and event.willCommit
Commit Settings: Checking 'Commit selected value immediately' is crucial; without it, the user would have to click outside the field for the JavaScript update to trigger.
Manage PDF Forms Effortlessly

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. 1. Open the PDF Document: Launch WPS Office and open your existing PDF file or create a new one.
  2. 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to reveal the interactive form toolkit.
  3. 3. Insert Form Controls: Select the desired controls, such as Text Fields, Checkboxes, or Combo Boxes, and drag them onto your document page.
  4. 4. Edit Properties: Double-click the added fields to customize their appearance, options, and behaviors, then save your interactive PDF.
Easy-to-use visual PDF form builder for quick document creationFully compatible with standard PDF formats and Adobe Acrobat formsLightweight application with fast rendering speedsSeamless interface for both beginners and advanced users
microsoft office alternative - wps office

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.