Skip to main content
Participating Frequently
Oct 12, 2016 11:13 AM UTC
Answered

Pop-up warning

I have this script that resets an icon via
another button without any warning

var oIconClear = getField("ClearIcon3").buttonGetIcon({nFace:0}); 

getField("Button2").buttonSetIcon({oIcon:oIconClear, nFace: 0}); 


How can I get added to the script a code that gives a warning (yes or no) and who
stops the action when clicked NO

This topic is closed to new replies. Start a new post to keep the conversation going.
Bernd Alheit
Bernd AlheitCorrect answer
Community Expert
Oct 13, 2016 9:21 AM UTC

// A MouseUp action
// ask question with 'yes/no' take action on 'yes'
if( app.alert({
cMsg: "Do you want to clear this document?", // message to display
cTitle: "Reset Form Warning", // title for pop-up box
nIcon: 2, // question icon
nType: 2 // yes/no buttons
}) == 4) {
this.resetForm();
}

var oIconClear = getField("ClearIcon3").buttonGetIcon({nFace: 0}); 
getField("Button2").buttonSetIcon({oIcon: oIconClear, nFace: 0}); 


Put the last 2 lines after this.resetForm();

7 replies

JR Boulay
Community Expert
Community Expert
Oct 12, 2016 8:12 PM UTC
Acrobate du PDF, InDesigner et Photoshopographe
AcronatAuthor
Participating Frequently
Oct 13, 2016 6:30 AM UTC

The problem is that I do not manage to get
"App Alert" feature to work with the script over.

It gives a warning but delete icon whether I press yes or no

Translate
try67
Community Expert
Community Expert
Oct 13, 2016 7:11 AM UTC

Post the code that you're using.

Translate
try67
Community Expert
Community Expert
Oct 12, 2016 11:15 AM UTC

You can use the app.alert() method to do that. More information is available in the Acrobat JavaScript API Reference.

Translate