Javascript help: submit button to use form field plus other text in Subject line
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.
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/
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
I'm getting an error:
SyntaxError: missing : after property id
1:
Thanks, I'll keep plugging away.
Copy link to clipboard
Copied
Ah! Got it!
cSubject:"Title of Form_" + this.getField("full_name").valueAsString});
colon instead of first equal sign
Copy link to clipboard
Copied
Correct, the code fragment was out of context, so I missed a couple of bits there. Good Catch!!
Use the Acrobat JavaScript Reference early and often

