Skip to main content
Inspiring
February 21, 2020
Question

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

  • February 21, 2020
  • 1 reply
  • 785 views

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.

This topic has been closed for replies.

1 reply

Thom Parker
Community Expert
Community Expert
February 21, 2020

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 PDFScriptingUse the Acrobat JavaScript Reference early and often
akunceAuthor
Inspiring
February 21, 2020

I'm getting an error:

SyntaxError: missing : after property id
1:

Thanks, I'll keep plugging away.

akunceAuthor
Inspiring
February 21, 2020

Ah! Got it!

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

colon instead of first equal sign