Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

capture checkbox values

New Here ,
Aug 19, 2016 Aug 19, 2016

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

form checkboxes.JPG

TOPICS
Acrobat SDK and JavaScript , Windows
635
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 19, 2016 Aug 19, 2016

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 19, 2016 Aug 19, 2016

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 20, 2016 Aug 20, 2016

I'm not seeing anything "below"... Did you mean to insert an image?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 20, 2016 Aug 20, 2016

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 21, 2016 Aug 21, 2016

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"});

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 21, 2016 Aug 21, 2016
LATEST

You are wonderful!  Thank you very much.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines