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

Issue with JavaScript Code for Dropdown Interaction in Adobe Acrobat

Community Beginner ,
May 25, 2023 May 25, 2023

I am experiencing an issue with a JavaScript code snippet that I am using to link two dropdown fields in Adobe Acrobat. I have a "Dropdown1" dropdown and a "Dropdown2" dropdown, and I want the selection in the "Dropdown1" dropdown to automatically update the value in the "Dropdown2" dropdown.

I have followed the instructions provided and tried different code snippets, but the functionality is not working as expected. When I select an option in the "Dropdown1" dropdown, the corresponding value does not update in the "Dropdown2" dropdown.

 

Steps taken:

  1. Verified the field names used in the JavaScript code and ensured they match the actual field names in the PDF document.
  2. Confirmed that JavaScript execution is enabled in my PDF viewer.
  3. Tested the PDF document in different viewers to check for any compatibility issues.
  4. Checked for conflicting scripts or actions that may interfere with the dropdown functionality.
  5. Ensured that I am using the latest version of Adobe Acrobat.

Despite these efforts, I have been unable to resolve the issue. I am seeking assistance in identifying the problem and finding a solution for the dropdown interaction.

 

var carDropdown = this.getField("Dropdown1");
var carIDDropdown = this.getField("Dropdown2");

carDropdown.setAction("OnBlur", "updateCarID()");

function updateCarID() {
  var selectedCar = carDropdown.value;

  switch (selectedCar) {
    case "USA":
      carIDDropdown.value = "USA";
      break;
    case "CANADA":
      carIDDropdown.value = "CANADA";
      break;
    case "Greenland":
      carIDDropdown.value = "Greenland";
      break;
    case "Iceland":
      carIDDropdown.value = "Iceland";
      break;
    default:
      carIDDropdown.value = "";
      break;
  }
}

 

Any guidance or insights into this issue would be greatly appreciated. Thank you in advance for your assistance.

TOPICS
JavaScript , PDF , PDF forms
429
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 Beginner ,
May 25, 2023 May 25, 2023

To be Deleted please

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 ,
May 26, 2023 May 26, 2023
LATEST

Do not use the OnBlur event. 

It looks like both drop downs are meant to be identical. If this is the case then just give them the same name. If something more complex is needed, then use code in the validate event. 

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