3 Replies Latest reply on Aug 26, 2012 3:09 PM by DHeadrick

    Combobox value is previous selection, not current selection


      This should be a very simple question.


      I'm using JavaScript on Acrobat 9 and I've created a combox with 4 values: 1, 2, 3 and 4.  I've set commitOnSelChange = true.  I've created a validation script to take the value just entered and update another field (so I'm not really doing true validation, I'm just using the validation script capability to update another field based on the combobox value just entered).


      The problem is very simple -- the value parameter is always set to the previous value.  If I select "1" and then select "3", the validation script upon selecting "3" will be seeing the previous "1".  If I then select "4", the validation script will see the previous value of "3".


      How do I deal with the CURRENT value parameter upon selecting it??  I don't want to have to click another button, like a Submit button, I just want to select some value from 1 to 4, and then process that value.


      In addition to the validation script, I've tried various JavaScript actions like Mouse Down, but those event handlers also always see the previous value, never the current value.


      I'm aware that I can use Custom Keystroke Scripts to somehow trigger on "event.willCommit", but I can't believe that would be necessary in simply attempting to select numeric values from 1 to 4.


      There must be *some* way to process a combobox's current value, ideas??




        • 1. Re: Combobox value is previous selection, not current selection
          MarkWalsh Level 4

          It's pretty hard to say what you're doing wrong, since you haven't included any of the code you are using.


          I'm guessing you're using something like this in your custom validation script:


          this.getField('TextBox').value = this.getField('ComboBox').value


          The control's 'value' property hasn't been updated to the new value yet in the Validation script. Try using event.value instead:


          this.getField('TextBox').value = event.value


          Or, better yet, put the code into the textfield's calculate script:


          event.value = this.getField('ComboBox').value

          • 2. Re: Combobox value is previous selection, not current selection
            George_Johnson MVP & Adobe Community Professional

            Mark likely nailed it, but note that if your combo box items have export values, event.value in the combo box's validate event will return the display value, and getting the value of the combo box in another field's calculate event will return the export value of the select item.

            1 person found this helpful
            • 3. Re: Combobox value is previous selection, not current selection
              DHeadrick Level 1

              Hi Mark,


              Thanks!!  I had never used "event.value" before, that's exactly what I needed to use.


              Code-wise, I had this before (basically, the code you showed):


                           this.getField('ComboBox').value;  // This always reports the previous value


              Now, in my validation script, I use event.value, and it all works!!


              It's always great to get a timely, concise answer, especially when I've probably spent 5 hours searching in vain for the answer myself.


              Thanks again.