2 Replies Latest reply on Dec 10, 2013 3:14 PM by wayrledx

    Custom Keystroke Script


      I'm using a Custome Keystroke Script for a dropdown box.

      Essentially when the user selects an option from the dropdown it poplulates another Text Box.


      This is the code that works.


      // Custom Keystroke script for combo box

      (function () {


      if (!event.willCommit) {


      // Set up an array of addresses. \r = carriage return

      var aAddr = [];

      aAddr[0] = "Data will be populated once a Title is Selected";

      aAddr[1] = "FAAPMG8 \r 8 \r Salaried";

      aAddr[2] = "FAACCO1 \r 1 \r Hourly";

      aAddr[3] = "ADADAS1 \r 1 \r Hourly";


      // Associate export values of combo box items

      // to corresponding index of address array

      var aIndex = [];

      aIndex[0] = 0;

      aIndex[1] = 1;

      aIndex[2] = 2;

      aIndex[3] = 3;


      // Get the export value of the selected item

      var ex_val = event.changeEx;


      // Get the corresponding address

      var addr = aAddr[aIndex[ex_val]];


      // Populate the text field with the address

      getField("JobDetails").value = addr;






      This was a sample I pulled from another forum and then modified for my needs. When I expand on this from 4 options to 67 options, enter that script into the editor and click OK the Format tab of the field properties reverts from Custom to None and deletes any data that was enteredin the script editor.


      There is no error but I'm wondering if there is a character or line limit that is stopping me from doing this. Any help is greatly appreciated. Customer Care tells me this is my only route for help.

        • 1. Re: Custom Keystroke Script
          George_Johnson MVP & Adobe Community Professional

          Looks like someting I wrote to address a specific problem of two or more dropdown items being associated with the same address. If this isn't the case with your dropdown, it can be simpler. The two arrays really should be defined in a document-level JavaScript so that they are initialized only once when the document is opened, as opposed to every time an item is selected from the dropdown.

          • 2. Re: Custom Keystroke Script
            wayrledx Level 1

            Thank you for the tip. I'll try that and see if it take it. This is my first attempt at scripting in Acrobat. I do have 2 drop downs with the same data but each one pointing to a different target form field. Basically it's is Current Job Title and New Job Title, the associated text box is then filled with Job Code, Job Grade and Pay Type. I'll post again if I run into any trouble.