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

alert box with Yes & No buttons?

NancyM
Registered: Sep 25 2006
Posts: 40

I am working in LiveCycle 7.0 and have created an alert box for my dymanic form that appears on exit of a text field.
 
example
 
app.alert("Is this correct?",2,2);
 
What I need to do upon the answer is:
 
if Yes is clicked some text and drop down fields need to be filled in.
if No these same fields need to be read only.

My Product Information:
LiveCycle Designer, Windows
sconforms
Expert
Registered: Jul 10 2007
Posts: 92
I would suggest you use the

xfa.host.messageBox("message", icon, buttons)

method where the icon parameter is 0 (error) to 3 (status) and the buttons parameter is 0 (OK), 1 (OK, cancel), 2 (yes, no), 3 (yes, no, cancel).

The method then returns an integer indicating which button was pressed: 1 (OK), 2 (cancel), 3 (no) or 4 (yes).

You would then have an IF statement like this:

var choice = xfa.host.messageBox("message", 2, 2); if (choice == 4)// fill-in fields: myField.rawValue = "default";else// set fields to read-only using the access property: myField.access = "readOnly";

Stefan Cameron obtained his bachelor's degree with Honors in Computer Science at the University of Ottawa and is a Computer Scientist working on Adobe's LiveCycle server products, in particular on LiveCycle Designer ES for the past 5 years.

NancyM
Registered: Sep 25 2006
Posts: 40
When I added the following to the exit event of the prior textBox field. I get this console message (see below).

var choice = xfa.host.messageBox("Will returns be filed?",2,2)
if (choice == 3)///answer no
{
_940.access = "readOnly";
}
else
{
_940.rawValue = "";//Allowing input into testBox filed
}Console message

GeneralError: Operation failed.
XFAObject.messageBox:1:XFA:F[0].P1[0].CityStateZip[0]:exit
Argument mismatch in property or function argument

When I change to app.alert the box appears and when answered yes input to the textField is allowed and I can tab to next field. But when no is the answer, I am able to input into the field but not tab out. I have found that if I setFocus to another textField and then try to go back to the field that was set to readOnly, it works.

var choice = app.alert("Will returns be filed?",2,2)
if (choice == 3)///answer no
{
_940.access = "readOnly";
xfa.host.setFocus("Dep940M");
}
else
{
_940.rawValue = "";
}