Copy link to clipboard
Copied
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
-
Text Box the Status is required.
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.
Copy link to clipboard
Copied
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");
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
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");
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.
Copy link to clipboard
Copied
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");
Copy link to clipboard
Copied
Nesa
That has worked perfectly, Thank you and Thom for your help on this.

