Skip to main content
Inspiring
August 12, 2024
Answered

How to use a combo box custom keystroke script to call a function

  • August 12, 2024
  • 4 replies
  • 3239 views

I simply want to use a combo box custom keystroke script to call a function when any item is chosen from the box's list. I found many examples and tried many unsuccessfully. My most recent attempt is this:

      if(event.changeEx != ""){this.ConcessionMaximum()}

Also tried referencing the export values (there are only three in the list) like this:

      if(event.changeEx == "con" || event.changeEx == "fha" || event.changeEx == "va"){

           this.ConcessionMaximum();

          }

Apologies for what seems a very elementary question, but I would appreciate a solution.

This topic has been closed for replies.
Correct answer try67

If you have export values it won't work with validate script, try using custom calculation script instead.

Your original script should work fine as keystroke script, are you sure you have right export values, also maybe it's issue in your function script perhaps?


Having export values does not prevent a custom validation script for working for this purpose. You just need to use the display value in the code, instead of the export value.

4 replies

PDF Automation Station
Community Expert
Community Expert
August 13, 2024

A validation script runs whenever the value of the field containing the script changes, so all you have to do is enter your function as a validation script.  You don't need any conditions.  If you don't tick "Commit select value immediately" in the options tab, the function will execute upon the blur event.  If you do tick it, the function will execute immediately after making a selection.

PDF Automation Station
Community Expert
Community Expert
August 12, 2024

Use this keystroke script:

 

if(!event.willCommit)

{this.ConcessionMaximum()}

Bernd Alheit
Community Expert
Community Expert
August 12, 2024

Check the Javascript console for errors.

Nesa Nurani
Community Expert
Community Expert
August 12, 2024

Is there a reason why you want to use keystroke script?

EDIT:
What happens when you use script?

ODuinnAuthor
Inspiring
August 12, 2024

Yes, because I want the script to execute when the selection is made. After the selection is made, the cursor is outside of the combo box and none of the other actions work satisfactorily. Nothing happens when I use the keystroke script.

try67
Community Expert
Community Expert
August 13, 2024

Use the Validate event, then. Make sure the option to commit the selected value immediately is ticked under the field's Properties, in the Options tab. This is much better than Keystroke, which will also launch when the user is just scrolling through the list using the keyboard.

The selected value can be referenced using event.value in your code.