1 Reply Latest reply on Apr 12, 2013 1:21 PM by gkaiseril

    Custom Keystroke Calculation

    P. Black Level 1

      I created a very simple form in Acrobat X Pro.  It is just a mileage report for some of our satellite locations.  I have a drop down box that lists all the locations.  I created a document Javascript that lists all these locations and the miles for each of them.

       

      var gMileList= new Array

      gMileList["Choose"] = 0
      gMileList["BRIC"] = 4
      gMileList["EQ"] = 7
      gMileList["FC"] = 8
      gMileList["PCCD"] = 3
      gMileList["SW"] = 4
      gMileList["TRGC"] = 26

       

      Then in the drop down box Format>Custom tab i added a custom keystroke script:

       

      var a= this.getField("RTMileage1")

      if (event.changeEx in gMileList)
      a.value=gMileList[event.changeEx]

       

      It works beautifully on my computer (windows 7, acrobat X Pro).

      I even reader enabled the form

       

      I sent it to my boss (windows 7, Acrobat XI Pro) and guess what it doesn't work.  He even tried opening it on his Mac with Acrobat X and it didn't work. 

       

      Can anyone help me with this.  Is it something in my script or is it a Acrobat X to Acrobat XI problem?

        • 1. Re: Custom Keystroke Calculation
          gkaiseril MVP & Adobe Community Professional

          What does not work?

           

          Have you set the drop down box to "commit value"?

           

          Way are you not testing for the "willCommit" being false.

           

          How are you populating the drop down list?

           

          I would just set the mileage and not do the whole computation.

           

          I would use a document level script to initialize the combo box item and optional value:

           

          function init() {
          // values for drop down box
          var gMileList= new Array(
          ["Choose", 0],
          ["BRIC", 4],
          ["EQ", 7],
          ["FC", 8],
          ["PCCD", 3],
          ["SW", 4],
          ["TRGC", 26]
          );
          // set combo box values
          this.getField("Combo Box2").setItems(gMileList);
          // clear mileage field
          this.resetForm(["RTMileage1"]);
          return true;
          } // end init function

          init();

           

          The a custom key stroke script of:

           

          if(event.willCommit == false) {

          var a= this.getField("RTMileage1")

          a.value = event.changeEx;

          }

           

          If there are duplicate values for the combo box then you would use a different approach.