• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Click button after drop down menu selection

Community Beginner ,
Feb 26, 2019 Feb 26, 2019

Copy link to clipboard

Copied

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.

TOPICS
Acrobat SDK and JavaScript

Views

313

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 26, 2019 Feb 26, 2019

Copy link to clipboard

Copied

You can use the script at dropdown #8

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 27, 2019 Feb 27, 2019

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 28, 2019 Feb 28, 2019

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 28, 2019 Feb 28, 2019

Copy link to clipboard

Copied

Use the code as validation script of the dropdown.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 27, 2019 Feb 27, 2019

Copy link to clipboard

Copied

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 PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 27, 2019 Feb 27, 2019

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 01, 2019 Mar 01, 2019

Copy link to clipboard

Copied

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 {

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 02, 2019 Mar 02, 2019

Copy link to clipboard

Copied

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 PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 02, 2019 Mar 02, 2019

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 02, 2019 Mar 02, 2019

Copy link to clipboard

Copied

Looks like that you use the old value, not the actual value.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 02, 2019 Mar 02, 2019

Copy link to clipboard

Copied

Hi Bernd, thanks for your patience with me, ok this makes sense. When I selection option 1 in drop menu 2, then select option 1 in drop menu 8, I get the error, but if I then select the matching value, I no longer receive the message. How would I get the value I selected instead of the previous/old value?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 02, 2019 Mar 02, 2019

Copy link to clipboard

Copied

LATEST

Compare this.getField("Q2C1").value with event.value

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines