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

Javascript help: submit button to use form field plus other text in Subject line

Explorer ,
Feb 21, 2020 Feb 21, 2020

Copy link to clipboard

Copied

I have a form for which I made a Submit button.

It will be sending the form to two different email addresses.

I was able to find examples of javascript so I can use one of the form's fields as a subject line, however I would also like to have some other text in the subject as well, and I just can't seem to figure out how to add that.

this.mailDoc({cTo: "email_1;email_2", cSubject: this.getField("full_name").valueAsString});

Before "full_name" I'd like to have the Title Of Form. So the email subject like would be "Title of Form_full_name"

I can't seem to get that to work... do I make it:

cSubject="Title of Form_" this.getField("full_name").valueAsString});

?

Please help.

TOPICS
Acrobat SDK and JavaScript

Views

418

Translate

Translate

Report

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 ,
Feb 21, 2020 Feb 21, 2020

Copy link to clipboard

Copied

You concatonate strings like this:

cSubject="Title of Form_" + this.getField("full_name").valueAsString});

The "+" is the concatonation operator.

Here's an article on string manipulation in JavaScript. It shows a few different ways to build strings:

 https://acrobatusers.com/tutorials/splitting-and-rebuilding-strings/

 

Here's an article on setting up email properties from a script. It also shows how to maniuplate strings:

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

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

Votes

Translate

Translate

Report

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
Explorer ,
Feb 21, 2020 Feb 21, 2020

Copy link to clipboard

Copied

I'm getting an error:

SyntaxError: missing : after property id
1:

Thanks, I'll keep plugging away.

Votes

Translate

Translate

Report

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
Explorer ,
Feb 21, 2020 Feb 21, 2020

Copy link to clipboard

Copied

Ah! Got it!

cSubject:"Title of Form_" + this.getField("full_name").valueAsString});

colon instead of first equal sign

Votes

Translate

Translate

Report

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 ,
Feb 21, 2020 Feb 21, 2020

Copy link to clipboard

Copied

LATEST

Correct, the code fragment was out of context, so I missed a couple of bits there. Good Catch!!

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

Votes

Translate

Translate

Report

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