Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Reset Form button

Avatar

Level 3

I've used the Reset Form button from the Object pallette, and it modified it to give a warning and a chance to cancel if you don't want to clear the form.  But it doesn't matter whether you choose to or not, it still clears the form.

Here's my code:

if(xfa.host.messageBox("This will clear all data from the fields and reset defaults.  Are you sure?", "Clear all form fields",2,2))
{
xfa.host.resetData();
xfa.form.remerge();
}

What have I done wrong?

Thanks,

Peta

1 Reply

Avatar

Level 9

Hi Peta,

The message box returns some integer value depending the button you have clicked. Search messageBox in the help. By getting the value of the returned value you can manipulate your script.Try the following.

var response = xfa.host.messageBox("This will clear all data from the fields and reset defaults.  Are you sure?", "Clear all form fields",2,2);

app.alert(response);// This line is only for your information to check what's returning.

if (response == 4) // As in your case Yes returns '4' No returns '3'

     {

        xfa.host.resetData();
        xfa.form.remerge();

     }

else

     {

          Some code you want to execute.

     }

Thanks,

Bibhu.