Planet PDF Forum Planet PDF Forum
  New Posts New Posts RSS Feed - run function the instant combobox value changes
  FAQ FAQ  Forum Search   Register Register  Login Login


Hi, welcome to the Foxit Planet PDF Forum. If you have PDF or Adobe Acrobat questions then the right place to ask them is here, in this forum.

run function the instant combobox value changes

 Post Reply Post Reply
Author
morrison View Drop Down
New Member
New Member
Avatar

Joined: 26 Jan 2015
Points: 32
Post Options Post Options   Quote morrison Quote  Post ReplyReply Direct Link To This Post Topic: run function the instant combobox value changes
    Posted: 11 Apr 2017 at 4:51pm
Good morning.

I'm trying to get a function that populates text fields to run the moment a combobox's selection changes, not after the user clicks in another form field.  Is this possible?

Each unique option in the combobox will populate a name in one text field and a number in another text field.  Since this has to work for returning users who already have a value saved in the combo box, the function is at document level, and the call to the function is on page1>open.  That works beautifully for returning users who have a previously-saved selection in the combobox. 

However, I also need it to work if the user has no previous selection, as well as when the combobox selection is changed.  We will have users who are going in the form solely for the purpose of changing the selection and jumping directly to the save button.  Therefore, they are not expecting to have to click in another field to see their new selection change the values in the name and number text fields.  They're going to panic and not want to click save.

Things I've tried:
  • applying the script to various mouse triggers in the combobox -- works, but users have to click in another form field to effect change
  • custom keystroke -- values displayed are old news (stale, meaning only event related to previously-clicked selection occurs)

Here are the custom keystroke scripts that triggered the stale values populating:

if(event.willCommit) {
  if(event.value == "" | event.value=="Select a code") this.resetForm(["agency_name","agency_tin"]);
  else populateAgency();
}

// and the other

if(!(event.value=="") && !(event.value=="Select a code")){
  populateAgency();
}

if(event.value=="" | event.value=="Select a code"){
  this.resetForm(["agency_name","agency_tin"]);
}


P.S. - I do have "commit selected value immediately" selected.

Any ideas, or is there just not enough control over time of execution to make the field value change happen instantaneously?

Thank you,

~morrison

Back to Top
Sponsored Links


Back to Top
Rob Lyman View Drop Down
New Member
New Member
Avatar

Joined: 12 May 2015
Location: Chicago
Points: 25
Post Options Post Options   Quote Rob Lyman Quote  Post ReplyReply Direct Link To This Post Posted: 12 Apr 2017 at 8:58pm
Bear in mind that at the moment the keystroke script is being run, the field's value may not have been updated yet. In other words, "field.value" will hold the previous value, but "event.value" will hold the new (i.e. candidate) value.

This could explain why you are seeing 'stale' values in the other fields: you appear to be calling a method that will update those fields, but the new values are not passed as arguments; I assume you're reading them from the "field.value", which may not yet be updated.

Note, however, that Acrobat's behavior can be different when "event.willCommit" is true in the keystroke script. I'd advise printing information to the console (use console.println()) to make sure you're getting the data you expect.
Rob Lyman
Software Engineer
http://www.datalogics.com
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.10
Copyright ©2001-2017 Web Wiz Ltd.

This page was generated in 0.000 seconds.