Skip to main content
Participant
April 9, 2024
解決済み

Form Fill - Creating Multi-Line under Dropdown

  • April 9, 2024
  • 返信数 1.
  • 1903 ビュー

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

})();

 

 

 

このトピックへの返信は締め切られました。
解決に役立った回答 Thom Parker

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. 

 

 

返信数 1

Thom Parker
Community Expert
Community Expert
April 9, 2024

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 PDFScriptingUse the Acrobat JavaScript Reference early and often
Participant
April 9, 2024

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. 

 

 

 

 

 

Thom Parker
Community Expert
Thom ParkerCommunity Expert解決!
Community Expert
April 9, 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. 

 

 

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