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

Javascript using Checkbox reference to submit

New Here ,
Jun 15, 2020 Jun 15, 2020

I have a form with a submit button that sends the form to certain email address.  I have a check box for a specific part of the form that when checked, would add another email to the submit button.  The submit button works fine but i can not figure out how to get it to look at the check box and if checked, add an additional email address when it is submitted.  

TOPICS
Acrobat SDK and JavaScript
1.6K
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 ,
Jun 15, 2020 Jun 15, 2020

Post your current code, please, as well as the name of the check-box in question.

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 ,
Jun 15, 2020 Jun 15, 2020

So i have my submit button coded to do two things currently 

First is to submit the form using that function from the Action

The second thing it does is Reset the Form.  

I have not attempted to code the 3rd action to the point it is saved and not working.  What i have tried didn't work since i am new to this so i just cleared it out.  Here is a photo of the properties of my submit button. 

Lastly, the check box i need to reference is called OtherWorkadobe help.pngexpand 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
Community Expert ,
Jun 15, 2020 Jun 15, 2020

You have to do it all using a script.

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 ,
Jun 15, 2020 Jun 15, 2020

Would you mind assisting me with what that script would look like? 

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 ,
Jun 15, 2020 Jun 15, 2020

You didn't answer my question regarding the name of the check-box, so I assumed it's "Checkbox1".

Here's the code:

 

var toAddress = "me@gmail.com";
if (this.getField("Checkbox1").valueAsString!="Off") toAddress+=";john@gmail.com";
this.mailDoc({cTo: toAddress});
this.resetForm();
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 ,
Jun 15, 2020 Jun 15, 2020

Thank you so much for your help

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 ,
Jun 15, 2020 Jun 15, 2020

I do have one more question, how would i add so that the Subject line is populated with a certain Text Field which is called Trailer Number?

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 ,
Jun 15, 2020 Jun 15, 2020

Like this:

 

var toAddress = "me@gmail.com";
var msgSubject = this.getField("Trailer Number").valueAsString;
if (this.getField("Checkbox1").valueAsString!="Off") toAddress+=";john@gmail.com";
this.mailDoc({cTo: toAddress, cSubject: msgSubject});
this.resetForm();
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 ,
Jul 18, 2024 Jul 18, 2024

Hello, I have a question pretaining to this community. What if there are 3-5 checkboxs that I want to submit an email to different list of DL's and mail based users what would that script look like?

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 ,
Jul 18, 2024 Jul 18, 2024
LATEST

Here's an article with a sample file that shows how to do this with a selection from a dropdown. It could easily be modified to use a checkbox.

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

 

Here's an article on programming with checkboxes. 

https://www.pdfscripting.com/public/Checkboxes-and-Radio-Buttons.cfm

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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