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

How to change email address when a check box is checked

thuril
Registered: Aug 20 2008
Posts: 3
Answered

Hello,
I'm kind of a newbie working with LiveCycle and need some help. I have created a document for our customers to complete and send in by email using the supplied submit button in the document. However, I need the document to go to one email address if a check box is checked and to another one if it isn't . I'm not even sure you can do that. Any help would be appreciated

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
This is actually a topic that comes up quite often. There are several different threads on the topic. Just search for "email" in JavaScript or Forms:LiveCycle forums and you'll find plenty. This is the best one.

http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=3102

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

thuril
Registered: Aug 20 2008
Posts: 3
Thank You for your response

After looking over some of the relate threads, I developed this script and put it in the preSubmit portion of the CheckBox2 Events. However, the document is still being sent to the sunbmit button url even if the box is checked. Do I have the script in the right area or is the script the problem? Any feed back be appreciated

myDoc.mailDoc({
var f = this.getField("CheckBox2");
if(f.isBoxChecked(0))
bUI: false,
cTo: "developpermit [at] vancecounty [dot] org;developpermit [at] vancecounty [dot] org",
cSubject: "Subject Line Text",
cMsg: "Message Text here",
else
bUI: false,
cTo: "developpermit [at] vancecounty [dot] org;developpermit [at] vancecounty [dot] org",
cSubject: "Subject Line Text",
cMsg: "Message Text here",

});
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Nice try!! but this code is not going to work.

If you are going to use the JavaScript "mailDoc()" fucntion then you can't use the email submit button because they conflict with each other. Actually the "Submit" button overides any code in the click event. Just use a regular form button.

After that, there are some problems with your code. First, replace "myDoc" with "event.target". In LiveCycle, and only in LiveCycle, "event.target" points to the "Document Object"

Next, code cannot be placed inside the function call. And, since this is a LiveCyle form the check box is accessed differently. The code here is for an AcroForm. I know it's confusing. Acrobat uses two different forms technologies. They are very different, but overlap a little. The code on your LiveCycle form should look like this:

if(CheckBox2.rawValue)event.target.mailDoc({....});elseevent.target.mailDoc({...});

Take a look at this video, it explains some of the concepts involved in programming LiveCycle forms.

https://admin.adobe.acrobat.com/_a200985228/p87746471/


Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script