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

Form Fill - Creating Multi-Line under Dropdown

New Here ,
Apr 09, 2024 Apr 09, 2024

Copy link to clipboard

Copied

I am working on creating a form filled document in Adobe Acrobat Pro 2020.  I have a few fields that require a dropdown with two unique addresses for user to choose from. Currently the field runs the address accross the page and I'd like to to do a multi-line to make better use of space.

 

I've seen different keystroke scripts for multi-line addresses in discussions over the several years but nothing I've added under Dropdown Properties/Format/Custom Keystroke Script is working?  Wondering if I have entered a wrong field in the script below? Should I be entering the addresses as part of the item under Options/Item?

 

Under General/Name I've entered "Location" 

 

Under Options/Item I have the following Items:

 

Item: Illinois

          Export Value: 0

 Item: Henrietta

           Export Value: 1

 

Commit selected value immediately is selected.

 

Under Dropdown Properties/Format/Custom/Custom Keystroke Script 

 

// Custom Keystroke script for combo box
(function () {

if (!event.willCommit) {

// Set up an array of addresses. \r = carriage return
var aAddr = [];
aAddr[0] = "555 Illinois BLVD.\rNew York, NY 10013";
aAddr[1] = "201 Henrietta St.\rNew York, NY 10019";

// Get the export value of the selected item
var ex_val = event.changeEx;

// Get the corresponding address
var addr = aAddr[ex_val];

// Populate the text field with the address
getField("location").value = addr;
}

})();

 

 

 

TOPICS
PDF forms

Views

465

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 , Apr 09, 2024 Apr 09, 2024

The error message is indicating that there is no field named "location" on the form. 

The comments indicate that "location" is the name of the text field that recieves the address. 

Check the field names and put the correct text field name in the script. 

 

 

Votes

Translate

Translate
Community Expert ,
Apr 09, 2024 Apr 09, 2024

Copy link to clipboard

Copied

Other than the closure function and a missing "this", the code looks good. 

I would have written it like this:

// Custom Keystroke script for combo box
// Set up an array of addresses. \r = carriage return
var aAddr = ["555 Illinois BLVD.\rNew York, NY 10013","201 Henrietta St.\rNew York, NY 10019"];
if (!event.willCommit) {
    // Get the corresponding address
    var addr = aAddr[event.changeEx];

    // Populate the text field with the address
    this.getField("location").value = addr;
}

 

The first thing to do when code is not working is to look in the Console Window to see if any errors are reported. 

 

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 ,
Apr 09, 2024 Apr 09, 2024

Copy link to clipboard

Copied

Hi Thom,  

 

I've attempted to enter your version of code and I'm still not getting the dropdown to populate with an address. See image #1 It remains the Item description under Options. See further below. I opened the console window with the script and the error I receive is in second image below.  Did I copy your code incorrectly? First time doing anything with keystroke scripts. 

Natasha36632249lnq5_0-1712701106846.png

 

Natasha36632249lnq5_1-1712701145832.png

 

Natasha36632249lnq5_2-1712701248245.png

Natasha36632249lnq5_3-1712701255890.png

 

 

 

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 ,
Apr 09, 2024 Apr 09, 2024

Copy link to clipboard

Copied

The error message is indicating that there is no field named "location" on the form. 

The comments indicate that "location" is the name of the text field that recieves the address. 

Check the field names and put the correct text field name in the script. 

 

 

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
Community Expert ,
Apr 10, 2024 Apr 10, 2024

Copy link to clipboard

Copied

LATEST

The drop-down field will not be populated with the address, but another field will (a multi-line text field).

Dropdowns are not multiline fields, although you can technically show a multi-line value in them, but it's undocumented and not recommended.

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