Skip to main content
Participating Frequently
October 12, 2016
Answered

Pop-up warning

  • October 12, 2016
  • 2 replies
  • 1087 views

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 has been closed for replies.
Correct answer Bernd Alheit

// 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();

2 replies

JR Boulay
Community Expert
Community Expert
October 12, 2016
Acrobate du PDF, InDesigner et Photoshopographe
AcronatAuthor
Participating Frequently
October 13, 2016

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

try67
Community Expert
Community Expert
October 13, 2016

Post the code that you're using.

try67
Community Expert
Community Expert
October 12, 2016

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