These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Reset Button with added option to select CANCEL or OK

suewhitehead
Registered: Jun 3 2008
Posts: 232
Answered

I would like to add the option to my Reset button for the user to have a dialog box popup giving him the option to Cancel the reset action or cllick OK to reset the form. It would also have a message that says "are you sure you want to remove all data from this form?"

I have been able to find a script that uses an app.response box to do this, but I don't want the box with the field that app.response gives. What other way could I do this?

This is the script I have now:
var cResponse = app.response({
cQuestion: "You are about to clear all data from this form. Are you sure you want to do this?"
});
if (cResponse == null){ //if Cancel is selected
app.alert("Data will not be cleared.");
cResponse = 0;
}
else
this.resetForm();

My Product Information:
Acrobat Pro 9.0, Windows
Dimitri
Expert
Registered: Nov 1 2005
Posts: 1389
Hi suewhitehead,

You could just use an app.alert dialog instead- it does not inlcude a text field entry but can include your text asking if the user really does wnat to reset the entire form.

Hope this helps,

Dimitri
www.pdfscripting.com
suewhitehead
Registered: Jun 3 2008
Posts: 232
Thanks. I am still having trouble. I am new to javascript so this is probably something simple.
I substituted app.alert in the script for app.response, but now the button doesn't do anything. What else do I need to change?

var cResponse = app.alert({
cQuestion: "All data will be cleared from this form. Are you sure you want to clear all data?",});
if (cResponse ==null){
//if Cancel is selected
app.alert("Data will not be cleared.");
cResponse = 0;
}
else
this.resetForm();
suewhitehead
Registered: Jun 3 2008
Posts: 232
Also, I want the user to have the option to click CANCEL so that the form will not be reset. Does an app.alert create a Cancel button? If not, how would I do it using app.alert?
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
The syntax of the method changes. Also if one takes action only for the "Yes" response there will be no need for the "else' action.

// display and get response - use the "?" Icon and "Yes/No/Cancel" return button
var cResponse = app.alert({
cMsg: "All data will be cleared from this form!/nAre you sure you want to clear all the data?",
nIcon: 2, nType: 3,
cTitle: "Clear Form"
});
// clear form only if response is "Yes"
if (cResponse == 4) {
this.resetForm();
}

George Kaiser

suewhitehead
Registered: Jun 3 2008
Posts: 232
Thanks so much, both of you. This is exactly what I needed.