Skip to main content
Abby8002
Participating Frequently
February 27, 2019
Question

Click button after drop down menu selection

  • February 27, 2019
  • 3 replies
  • 420 views

Hey everyone, been scouring the net and can't get my hands on this. Hoping you can help

In Acrobat, I need to automatically press a button after the user has made a selection from a drop menu.

OR, if it's easier - I need to show a message to the user if they select a different option in Dropdown #8 than they did in DropDown #2 - Both drop menus have the same values to choose from, but we can't automate them to be the same. The user is supposed to select the same answer but if they don't, we need to ask them if they are sure.

I've got the script to compare the fields in a button, so if I can just get the button to be pressed automatically after they select something in Dropdown menu #8, that'd be great.

Thanks in advance for any help

B.

This topic has been closed for replies.

3 replies

Abby8002
Abby8002Author
Participating Frequently
March 2, 2019

I ended up using this as on blur of drop menu #8. Thanks for your response .:)

var A = this.getField( "Q2C1").value; // the value of field A;

var B = this.getField( "Q8C1").value; // the value of field B;

var C = A - B; // the value of field A times the value of field B;

if( C != 0 ) {

app.alert("Question 8 must be equal to question 2. Please reconsider your response.");

} else {

}

Thom Parker
Community Expert
Community Expert
March 2, 2019

It is not a good idea to use the blur event. This event responds to a change in focus, not a change in field value. I would be much better to use the code in a validation script, as suggested by Bernd.

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Abby8002
Abby8002Author
Participating Frequently
March 2, 2019

Hi Thom, Yeah, I read somewhere too that the on blur isn't a good place. I've tried it as a validation script, but it's throwing the message even when the value of Q8 matches that of Q2....I'm not sure why.

Thom Parker
Community Expert
Community Expert
February 27, 2019

Here's an article on using a script to display a popup message.

https://acrobatusers.com/tutorials/popup_windows_part1

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Abby8002
Abby8002Author
Participating Frequently
February 28, 2019

Hi Thom, thanks for the reply, I did come across your article, but wasn't able to gleen from it how to press a button automatically after a selection is made form a drop menu or how to add an alert box only if the drop menu selection does not match user input on another drop menu within the form.

Bernd Alheit
Community Expert
Community Expert
February 27, 2019

You can use the script at dropdown #8

Abby8002
Abby8002Author
Participating Frequently
February 28, 2019

Thanks for responding Bernd, I tried putting the script on Dropdown #8, on the on blur but it doesn't work - This is why I wanted to automatically push the button after a selection is made on drop menu #8 - since the button does the job.... This is what works when I click the button. I'm not sure what I need to modify here if I place the code on Drop  menu #8 (Q8C1). Any ideas?:

this.getField("Q8C1").value;

if(this.getField("Q8C1").value!=this.getField("Q2C1").value)

{

app.alert("Question 8 must be equal to question 2. Please reconsider your response.");

}

Thanks again for taking the time to look at my question

B.

Legend
February 28, 2019

You cannot automate pushing a button. There is no trick or advanced feature to do this at all. You instead have to do what pushing the button would do, by adding code that does the same thing at the appropriate time.