Copy link to clipboard
Copied
Preface: I am new to JavaScript and I know nothing about this language.
I need some JavaScript code for the following: I created a form with 8 checkboxes and a submit button. If the boxes are checked, I want to populate the address field of an email (w/ one or multiple addresses). For example: if Child Care and Sound Tech are checked, the email address field should be populated with Childcare@test.com; Soundtech@abc.com. If nothing is checked, prompt with an error msg. Moreover, I want the email sent in the background without the user having to click the send button.
Your assistance is appreciated
BrendaHC
Copy link to clipboard
Copied
What are the names of the check-boxes? Did you set the email addresses as their export values, or do you want to hard-code them into the script?
Your second request (sending the data by email silently) is not possible, not unless a script is installed on the user's local machine, and even then they have to allow it at least once.
Copy link to clipboard
Copied
The names of the boxes are below. In the form they are named as defaulted, i.e. Check box 35.
I planned on hard coding the email addresses, unless there is a better way. Again, I don't know Javascript.
Copy link to clipboard
Copied
I'm not seeing anything "below"... Did you mean to insert an image?
Copy link to clipboard
Copied
Yes, I inserted an image in the original email and on my 1st reply.
Check Box34 - export value = CC
Check Box35 - export value = FAC
Check Box36 - export value = Hop
Check Box37 - export value = MM
Check Box38 - export value = MD
Check Box39 - export value = Mus
Check Box40 - export value = St
Check Box41 - export value = Vt
Thank you
Copy link to clipboard
Copied
OK, so you can use something like this as the custom MouseUp code for the Submit button:
var emails = []
if (this.getField("Check Box34").value!="Off") emails.push("Childcare@test.com");
if (this.getField("Check Box35").value!="Off") emails.push("Soundtech@abc.com");
// etc.
if (emails.length==0) {
app.alert("Error! You must first select some recipients for the form.",1);
} else {
this.mailDoc({cTo: emails.join(";"), cSubject: "Enter the email subject line here", cMsg: "Enter the email message body here"});
}
Copy link to clipboard
Copied
You are wonderful! Thank you very much.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now