Skip to main content
Known Participant
March 4, 2019
Answered

Submit completed form to mandatory recipients and user selected recipients

  • March 4, 2019
  • 1 reply
  • 1216 views

There's a portion in my form that asks user if it is "New" or "Change", both options will have to go through an approval process.

I have set up the New option, but not the "Change" option.

If "Change" is selected, the form has to be sent to mandatory recipients and user selected selected recipients? Is it possible to let the user select from a list of email addresses? The user can select more than 1 from the list, along with the mandatory recipients. How do I do it?

This topic has been closed for replies.
Correct answer try67

Here's the basic code to do it:

var emails = [];

for (var i=1; i<=8; i++) {

    var v = this.getField("EmailBox"+i).valueAsString;

    if (v!="Off") emails.push(v);

}

if (emails.length==0) app.alert("Error! You must tick at least one email box.");

else this.mailDoc({cTo: emails.join(";")});

In order for it to work you need to name your fields "EmailBox1" to "EmailBox8" and put the email address as their export value.

1 reply

Thom Parker
Community Expert
Community Expert
March 4, 2019

See the example in this article:

https://acrobatusers.com/tutorials/list_and_combo_in_lc

It shows how to pick emails off of a list

Here is an article on setting the email with a script

https://acrobatusers.com/tutorials/dynamically-setting-submit-e-mail-address

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Known Participant
March 5, 2019

Thank you for the links.

I've checked and read both links yet I am still having a hard time understanding it.

Is it possible to just assign an email address in every check box and let users check/select the addresses? And a submit button that gathers all selected email addresses and use it as the recipient?

Something like below. First 2 are mandatory so those boxes will be checked by default.

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
March 5, 2019

Here's the basic code to do it:

var emails = [];

for (var i=1; i<=8; i++) {

    var v = this.getField("EmailBox"+i).valueAsString;

    if (v!="Off") emails.push(v);

}

if (emails.length==0) app.alert("Error! You must tick at least one email box.");

else this.mailDoc({cTo: emails.join(";")});

In order for it to work you need to name your fields "EmailBox1" to "EmailBox8" and put the email address as their export value.