This script will work as long as the code is always 3 numbers and appears at the very front of the string.
Place this code in the custom "Format" script for the dropdown.
event.value = event.value.substr(0,3);
This did work in acrobat. However, I have a second hurdle which is that I am uploading this form to a construction software that sometimes doesnt recognize all the formulas and this one appears to be one of them. The software utilizes a 3rd party pdf view called PSPDFKit.
Any suggestions to either another way of getting it to work or a work around would be greatly appreciated.
That would require finding out what works in that application and what doesn't, which can be a lot of work. It's likely there's no support at all for scripting in it.
You are correct and I have been sending reports to the construction software's staff about each incident. But some script has worked and actually they tout how they have incorporated some basic script to work with their software for such things as project name and project number. What has worked for me to date are calculation scripts and if/then scripts. This was my first attempt at a drop down format script which they probably haven't developed yet on their end.
I appreciate all the feedback and will try some things out myself if I don't hear back from anyone more on this.
Thanks to all,
3rd party PDF viewer companies will usually provide a list of JS objects, functions, and properties they support. Unfortunately the issue here is which events they support. The Format script is pretty simple. If it doesn't work, then they do not support this event, and this won't work for your form.
I would suggest a couple of different approaches.
1. Make the drop down so small that only the code is visible.
2. Place a field next to the dropdown for displaying the code, then use a calculation script to set the value of the field to the code. It is highly likely that if they support any scripting that they support the Calculation event.
I was actually going to do that before I originally posted. I think I may have to do that if it becomes too much of a bother. The other thing I was thinking was to just make the form field small enough to where it just display 3 digits and set the justification to the left.
Thanks for all your help,