Expand my Community achievements bar.

Message box options

Avatar

Former Community Member

Hi

I have placed a reset button on my form. Now I want the user to choose whether to reset the form or not. I can make the message box come up with the right buttons, but I don’t know how to adjust the script to actually not reset the form when choosing NO.

I have placed this script on my reset button.

xfa.host.messageBox("Are you sure you want to erase ALL data on this form and start over?","Reset Titel",1,2)

xfa.host.resetData();

xfa.form.remerge();

Kirstine

3 Replies

Avatar

Level 10

You can use the return value of the messageBox function to check whether user has selected Yes / No..

if(xfa.host.messageBox("Are you sure you want to erase ALL data on this form and start over?","Reset Title",2,2) == "4"){
xfa.host.resetData();
xfa.form.remerge();
}

Thanks

Srini

Avatar

Former Community Member

Hi Srini

It works perfect!

Then I have an additional question because I'll like to understand why it works.

Dok2.jpg

I hope you will take the time to explain the details.

Regards

Kirstine

Avatar

Level 10

Since you are asking user to make a decision to reset data, it would be better to display a Question icon instead of Information icon.

MessageBox is a function which returns a response back. So in your code, 4 is returned when you select "Yes" button in the messageBox window..

Hope this helps..

Thanks

Srini