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

messageBox w/ Yes/No integer capture and gotoURL

bjasman
Registered: Apr 6 2010
Posts: 37
Answered

I am trying to have a message box appear before the form loads with a disclaimer and YES/NO buttons. If the users clicks YES, I would like a web page to open with a particular URL, if they click NO then the form will just load. Here is the code I have so far. The messageBox opens fine, but if they click YES, the URL does not open. The form just opens like normal. Any ideas on what I am doing wrong?

form1::ready:layout - (JavaScript, client)

var message;
if (xfa.host.name != "XFAPresentationAgent")
{
message = "Disclaimer";
message += "\n\n";
message += "For your convenience, this form has been made available in an electronic format. The form can be completed and submitted via e-mail using a computer and an electronic signature.";
message += "\n\n";
message += "If you prefer, you can print the form, complete it, and send it to us by US Mail. We prefer to receive this document in an electronic form via e-mail, however, no fees or penalties will be charged to you for sending in a paper form.";
message += "\n\n";
message += "This form must be completed for each producer you choose to list. To complete the form electronically you will need Adobe Acrobat Reader.";
message += "\n\n";
message += "Do you want to install or update Adobe Acrobat Reader now?"
xfa.host.messageBox(message, "Adobe Acrobat Reader Required", 3, 2);
}

var button = xfa.host.response(message, "Adobe Acrobat Reader Required", 3, 2);
if (button == 4)
{
xfa.host.gotoURL("http://www.adobe.com/go/acrobat");
}

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Hi,

I corrected your script a some way.
So I replaced the function "response" with "messageBox", because you don't need it this scenario.

var message = "Disclaimer";message += "\n\n";message += "For your convenience, this form has been made available in an electronic format. The form can be completed and submitted via e-mail using a computer and an electronic signature.";message += "\n\n";message += "If you prefer, you can print the form, complete it, and send it to us by US Mail.  We prefer to receive this document in an electronic form via e-mail, however, no fees or penalties will be charged to you for sending in a paper form.";message += "\n\n";message += "This form must be completed for each producer you choose to list.  To complete the form electronically you will need Adobe Reader.";message += "\n\n";message += "Do you want to install or update Adobe Reader now?"; if(xfa.host.name != "XFAPresentationAgent"){if(xfa.host.messageBox(message, "Adobe Reader Required", 2, 2)==4){app.launchURL("http://get.adobe.com/de/reader/", true);}else{//do nothing or something like closing the form....}}

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

bjasman
Registered: Apr 6 2010
Posts: 37
Thanks for the response. I made some changes to my code and tried several things based on your feedback. It's getting closer, but still not quite working. Does it have to do with having the script on the layout:ready event? Should it be on a different event?

The message box shows, but you have to click twice on the Yes or No button for something to happen. Also, do I need an "Else" statment if I just want the No button to do nothing and continue opening the form?

Code:

form1::ready:layout - (JavaScript, client)

var message;

if(xfa.host.name != "XFAPresentationAgent")
{
message = "Disclaimer";
message += "\n\n";
message += "For your convenience, this form has been made available in an electronic format. The form can be completed and submitted via e-mail using a computer and an electronic signature.";
message += "\n\n";
message += "If you prefer, you can print the form, complete it, and send it to us by US Mail. We prefer to receive this document in an electronic form via e-mail, however, no fees or penalties will be charged to you for sending in a paper form.";
message += "\n\n";
message += "This form must be completed for each producer you choose to list. To complete the form electronically you will need Adobe Reader.";
message += "\n\n";
message += "Do you want to install or update Adobe Reader now?";
xfa.host.messageBox(message, "Adobe Acrobat Reader Required", 3, 2);
}if(xfa.host.messageBox(message, "Adobe Reader Required", 3, 2) == "4")
{
app.launchURL("http://get.adobe.com/reader/", true);
}
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Put the code into the initialize:event.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

bjasman
Registered: Apr 6 2010
Posts: 37
Works! Thanks for your help!
bjasman
Registered: Apr 6 2010
Posts: 37
If anyone is interested, this is what my code ended up to be:

form1::initialize - (JavaScript, client)

var message;

{
message = "Disclaimer";
message += "\n\n";
message += "For your convenience, this form has been made available in an electronic format. The form can be completed and submitted via e-mail using a computer and the electronic acknowledgment.";
message += "\n\n";
message += "If you prefer, you can print the form, complete it, and send it to us by US Mail. We prefer to receive this document in an electronic form via e-mail, however, no fees or penalties will be charged to you for sending in a paper form.";
message += "\n\n";
message += "This form must be completed for each producer you choose to list. To complete the form electronically you will need Adobe Acrobat Reader. To install Acrobat Reader, go to http://get.adobe.com/reader/ and follow the instructions.";
message += "\n\n";
message += "Do you want to submit this application in electronic format via email? (Clicking No will allow you to access a printable version of the application.)";
}if(xfa.host.messageBox(message, "Adobe Reader Required", 3, 2) == "3")
{
xfa.resolveNode("form.ElectronicAcknowledgment").presence = "invisible";
xfa.resolveNode("form.ManualAcknowledgment").presence = "visible";
xfa.resolveNode("form.AttachFilesElectronic").presence = "invisible";
xfa.resolveNode("form.AttachFilesManual").presence = "visible";
xfa.resolveNode("form.EmailSociety").presence = "invisible";
xfa.resolveNode("form.PrintListingApp").presence = "visible";
}