Skip to main content
mylessaron
Participant
February 18, 2024
Question

change the output text of a dropdown list

  • February 18, 2024
  • 1 reply
  • 677 views

Is it possible to change the output text of a dropdown list? 

 

My list says for example, "Consolidated Electrical Manufacturing Company" , but when selected, all I want to appear is "CEMC" and not the full name. 

This topic has been closed for replies.

1 reply

Thom Parker
Community Expert
Community Expert
February 18, 2024

Yes, a custom format script would do this. 

For example

 

event.value = event.value.match(/\b(\w)/g).join("");

 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
mylessaron
Participant
February 19, 2024

This doesn't seem to work for me.... how exactly would this code work with the following selection.... "Los Angeles - Alhambra Courthouse" when selected would turn into "Alhambra Courthouse" as the output?

Nesa Nurani
Community Expert
Community Expert
February 19, 2024

Use like this:

if(event.value == "Consolidated Electrical Manufacturing Company")
event.value = "CEMC";
else if(event.value == "Los Angeles - Alhambra Courthouse")
event.value = "Alhambra Courthouse";