Need JScript fix: Alert box cancel button not working!

Avatar

Avatar

Wildau

Avatar

Wildau

Wildau

11-11-2014

Hello all,

My form has an option for the user to delete subforms/records as needed. Acrobat does allow for Undo- so if my user accidentally clicks "delete", they're stuck.

I added an alert box to ask "Are you sure...", with "yes" and "cancel" buttons.  But when I click the cancel button, it deletes anyway!

Here is the script I'm using:

if(xfa.host.messageBox("Are you sure you want to delete? This cannot be undone.","Confirmation Required !!!",2,2)==4)

{

     xfa.host.Delete.click();  

}

else

{

     xfa.host.cancel.Action=2;

}

and here's the form:

Dropbox - AFBS_90-Plus_110614.pdf

Many thanks!

Laura

View Entire Topic

Avatar

Avatar

radzmar

MVP

Avatar

radzmar

MVP

radzmar
MVP

20-12-2016

Ok, a submit button doesn't use a custom script to execute the submitting of the form or its data. So, to cancel the the submitting you have to use a script in the preSubmit event.

if (xfa.host.messageBox("Are you sure you want to send the form?", "Send form?", 2, 2) !== 4) { 

  xfa.event.cancelAction = true; // Cancel sending process if user selects not 'Yes'

}