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

submit form to 1 or 2 recipients depending on state of radio/checkbox

Michelangelo
Registered: Feb 10 2011
Posts: 6
Answered

Am trying to get my form to submit to 1 or 2 recipients depending on the state of a radio/checkbox yes or no.
 
Tried show/hiding submitbuttons but gave problems, seen the javascript insert recipient solution but can't get it to work on this..
 
any ideas how to set this up? form is fine, can put in 2 buttons to send to either 1 or 2 addresses but would like a cleaner solution that will change recipients on submitbutton.
 
fyi, email recipients are pre-known at initialization of form.
 
just can't figure this out..
   

My Product Information:
Acrobat Pro Extended 9.1.3, Macintosh
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Be a bit more specific. Which code did you use, and what was the result?

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

Michelangelo
Registered: Feb 10 2011
Posts: 6
tried fiddling with the conditional execution as explained here http://acrobatusers.com/tutorials/conditional-execution, which seems to be the solution i need. Am fairly new on using javascript on forms so proper syntaxing this thing is my main problem.

Thanks for the response btw.
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Accepted Answer
So let's say the name of your check-box is CheckBox1 and the on-value is Yes.
You can do something like this (of course, you can adjust the actual details):

cb1 = this.getField("CheckBox1").value;
if (cb1=="Yes") {
// Submit the form to a single address
this.mailDoc(bUI:false, cTo:"address [at] server [dot] com", cSubject: "Email subject", cMsg: "Email body"});
} else {
// Submit the form to two addresses
this.mailDoc(bUI:false, cTo:"address [at] server [dot] com;address2 [at] server [dot] com", cSubject: "Email subject", cMsg: "Email body"});
}

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

Michelangelo
Registered: Feb 10 2011
Posts: 6
i'll try it & let you know, looks like it's exactly what's needed, thanks!
Michelangelo
Registered: Feb 10 2011
Posts: 6
try67,

am getting an error about a missing ) after argument list 4: at line 5..

sorry for being such a noob, can't seem to place this missing ) in the right place.. syntax seems correct to me..
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Sorry, I neglected to add the opening curly brackets in the begining of the mailDoc commands. It should have been:

cb1 = this.getField("CheckBox1").value;
if (cb1=="Yes") {
// Submit the form to a single address
this.mailDoc({bUI:false, cTo:"address [at] server [dot] com", cSubject: "Email subject", cMsg: "Email body"});
} else {
// Submit the form to two addresses
this.mailDoc({bUI:false, cTo:"address [at] server [dot] com;address2 [at] server [dot] com", cSubject: "Email subject", cMsg: "Email body"});
}

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

Michelangelo
Registered: Feb 10 2011
Posts: 6
wow, great spotting that one, it's working!!! albeit in exact opposite, checked value YES sends 1 mail, unchecked sends 2..


thanks for your efforts, great help!
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Just add the extra address to the first mailDoc command (semi-colon separated), and remove it from the second one.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

Michelangelo
Registered: Feb 10 2011
Posts: 6
switched the mailDoc's around and it works like a charm! thanks again.
rm304
Registered: Oct 21 2011
Posts: 1
I tried adding this script to a button and it does not work for me? What am I doing wrong?