• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Drop down list selection displays a different value

New Here ,
Feb 14, 2018 Feb 14, 2018

Copy link to clipboard

Copied

Hello,

I have an employee timesheet that I am trying to setup. Time is entered in per Phase Code that is set up by job (not every job we have uses the same sequence of codes). To make it easier for the guys in the field so they dont have to memorize each code and what it stands for, I would like the drop down menu to display the code plus the description of the code but when a selection is made only display the code number. (i.e. "201 - Metal Studs" is shown in the drop down selection but when selected only "201" is shown). Is this possible? There are anywhere from 5 to 100 codes for any given project.


To date, I havent tried anything and havent had luck finding anything online. Thanks in advance.

TOPICS
Acrobat SDK and JavaScript

Views

508

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 15, 2018 Feb 15, 2018

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);

Votes

Translate

Translate
Community Expert ,
Feb 15, 2018 Feb 15, 2018

Copy link to clipboard

Copied

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);

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 16, 2018 Feb 16, 2018

Copy link to clipboard

Copied

Thom,

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.

thanks,

adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 16, 2018 Feb 16, 2018

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 16, 2018 Feb 16, 2018

Copy link to clipboard

Copied

try67,

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,

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 16, 2018 Feb 16, 2018

Copy link to clipboard

Copied

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.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 16, 2018 Feb 16, 2018

Copy link to clipboard

Copied

LATEST

Thanks Thom,


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,

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines