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

PDF Form Multiple Drop downs with same selection Value to List Field data in Status Text field.

New Here ,
Jan 14, 2022 Jan 14, 2022

Hello

 

I am brand new to Javascript within functioning PDF forms and have been struggling for days to try and create the following function within my form.

 

I currently have 14 Dropdown boxes all with the same selections. The reason for this is to highlight the status of 14 asset’s within my company.

The selections are

Serviceable

Unserviceable

Away

Loaned

 

When a particular selection is made, I want a details in a text box to display, Asset Serial No and Remarks all filled in within different fields on the form. For example.

 

 

 

 

When Unserviceable is selected in the drop down box (Aircraft 2). In a text box called (Details AOG) I would like a statement created in the following format built up from ‘Tail’ – ‘Remarks’ to note there is also 14 fields for Tail an Remarks as the form is built for all 14 assets. If possible I would like this to appear or disappear depending if the A

ZZ331- Engine 2 Fail

Andrew22663495c3vk_0-1642207422663.pngexpand image

 

 -

Andrew22663495c3vk_1-1642207422691.pngexpand image

 

 

Andrew22663495c3vk_2-1642207422695.pngexpand image

 

Text Box the Status is required.

Andrew22663495c3vk_3-1642207422697.pngexpand image

 

 

 

I have been all over the Adobe community page and the help on here is fantastic. If anyone can direct me or offer me the Javascript they would use I would be really grateful.

2.6K
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
Jan 16, 2022 Jan 16, 2022

See if this works for you:

var values = [];
for (var i=1; i<=14; i++) {
var v = this.getField("Aircraft"+i).valueAsString;
var t = this.getField("Tail"+i).valueAsString;
var r = this.getField("Remarks"+i).valueAsString;
if (v == "Unserviceable") values.push(v+" "+t+" "+r);}
event.value = values.join("\n");

View solution in original post

Translate
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 ,
Jan 14, 2022 Jan 14, 2022

If possible I would like this to appear or disappear from the DetailsAOG Text field depending if the drop box has selected unserviceable or not.

Translate
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 ,
Jan 14, 2022 Jan 14, 2022

When you post a question you always need to tell the program you are using
There are MANY programs in a full subscription, plus other non-subscription programs
Please post the exact name of the Adobe program you use so a Moderator may move this message to that forum

Translate
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 ,
Jan 15, 2022 Jan 15, 2022

Apologies

 

The program I created the PDF form on is:

 

Adobe Acrobat Pro DC (32-bit).

 

Again any help would be awesome, I am little stuck trying to get this to work.

 

Translate
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 ,
Jan 15, 2022 Jan 15, 2022

What you are asking about is somewhat complex.

You should start with basic form scripting here:

https://www.pdfscripting.com/public/PDF-Form-Scripting.cfm

 

Since the "details" are coming from multiple fields, use a custom calculation script in the details field to assemble the text.    

https://www.pdfscripting.com/public/Calculating-field-values-and-more.cfm

 

You stated that there are several dropdowns with the same options. Do all dropdowns operate in the same way. With the exact same fields?  or the same type of fields in a different sections or groups?  Names are extremely important for this type of scripting. With the correct names you can write one script that will work for all of the different dropdowns.

 

  

 

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

Translate
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 ,
Jan 16, 2022 Jan 16, 2022

Thom

 

Thanks for the reply, I will look at those links this evening. I have 14 dropdowns named "Aircraft1 to 14" they all have the same list items Serviceable, Unserviceable, Away and Loaned. They all operate the same way and indicate the same for all 14 assets.

 

I have the following Javascript in the custom calculation script. It Currently allows when I select an Asset Unserviceable to indicate unserviceable in the "DetailsAOG" but that is it.

 

var values = [];
for (var i=1; i<=14; i++) {
var f = this.getField("Aircraft"+i);
var v = f. valueAsString;

if (v!="Serviceable" && v!="Away" && v!="Loaned") values.push(v);
}

event.value = values.join("\n");

 

Andrew22663495c3vk_0-1642370555343.pngexpand image

 

 

Ideally I would like when I select an Asset Unserviceable. The Asset Serial No and Remarks for the Asset is indicated.  

 

Any thoughts or ideas would be really grateful.

 

Translate
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 ,
Jan 16, 2022 Jan 16, 2022

See if this works for you:

var values = [];
for (var i=1; i<=14; i++) {
var v = this.getField("Aircraft"+i).valueAsString;
var t = this.getField("Tail"+i).valueAsString;
var r = this.getField("Remarks"+i).valueAsString;
if (v == "Unserviceable") values.push(v+" "+t+" "+r);}
event.value = values.join("\n");

Translate
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 ,
Jan 17, 2022 Jan 17, 2022
LATEST

Nesa

 

That has worked perfectly, Thank you and Thom for your help on this.

 

 

Translate
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