Uncheck checkbox using app alert method when responding 'no'
Copy link to clipboard
Copied
I have an interactive PDF form designed/developed in Acrobat Pro 2017 containing (18) checkboxes all of which have the same name but different export values to allow an end-user to check only one checkbox. Also, checking a checkbox activates an app.alert method with a message requiring a 'yes' or 'no' answer. If the user chooses to answer 'yes' everything works as intended. My only problem is that while the user can easily enough clear the checkbox thereafter or check another checkbox to clear the existing checkbox, is there a script I can invoke to clear the checkbox if the user should decide to select/click 'no' to the message provided in the app.alert? I believe I have tried everything but for whatever reason have been unable to find a solution. Thank you ahead of time.
Copy link to clipboard
Copied
You can do it like this:
if (app.alert("?",2,2)==3) event.target.value="Off";
Copy link to clipboard
Copied
Thank you. While I knew the answer had to be something simple, I couldn't figure it out. Anyway, I ended up using the following script:
if(btn==3)
event.target.value="Off";
and needless to say, it worked like a charm.
Admittedly, I was not aware of event.target.value='off'; I will have to look at my latest Acrobat API reference guide under event to see where this is referenced. Thanks again.
Copy link to clipboard
Copied
Try67
Looked at the Acrobat API under the event property value and while all examples provided are easy enough to understand, I didn't find anything close to or resembling event.target.value='off'. Can you by chance tell me where Adobe may have provided an example similar to this or how you became aware of this script? Thank you ahead of time.
Copy link to clipboard
Copied
I can't tell you where where I learned it, probably on these forums (in one of its former iterations; I think this is the fourth forum system I've experienced here)...
The thing is that unlike a text field or a drop-down, a check-box (or a radio-button) field doesn't have a validation or calculation event, so we use the MouseUp event instead, which is triggered after a selection has been made. We use event.target to access the target field that triggered the event, and then value just returns that field's current value. We can read this property to know what's the new value of the field or write to it (like in this case) to override the user's selection.
Copy link to clipboard
Copied
Hear is an article that explains how to use the alert box for all kinds of things:
https://acrobatusers.com/tutorials/popup_windows_part1/
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
Thanks Thom.
Copy link to clipboard
Copied
Just a tip in that tutorial it says return values are 0,1,2,3 but it's actually 1,2,3,4.
Copy link to clipboard
Copied
Excellent point
Use the Acrobat JavaScript Reference early and often

