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.
Copy link to clipboard
Copied
You can use the script at dropdown #8
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.
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.
Copy link to clipboard
Copied
Use the code as validation script of the dropdown.
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
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.
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 {
}
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.
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.
Copy link to clipboard
Copied
Looks like that you use the old value, not the actual value.
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?
Copy link to clipboard
Copied
Compare this.getField("Q2C1").value with event.value